Skip to content

Commit 3485be8

Browse files
committed
Only look for temporary dtors if necessary
1 parent 69b5d4e commit 3485be8

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,29 +1170,33 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf,
11701170
return;
11711171
}
11721172

1173-
CXXDestructorDecl *referenceTemporaryDtor = nullptr;
1174-
if (const clang::RecordType *rt = e->getType()
1175-
->getBaseElementTypeUnsafe()
1176-
->getAs<clang::RecordType>()) {
1177-
// Get the destructor for the reference temporary.
1178-
if (const auto *classDecl = dyn_cast<CXXRecordDecl>(
1179-
rt->getOriginalDecl()->getDefinitionOrSelf())) {
1180-
if (!classDecl->hasTrivialDestructor())
1181-
referenceTemporaryDtor =
1182-
classDecl->getDefinitionOrSelf()->getDestructor();
1183-
}
1184-
}
1185-
1186-
if (!referenceTemporaryDtor)
1173+
const QualType::DestructionKind dk = e->getType().isDestructedType();
1174+
if (dk == QualType::DK_none)
11871175
return;
11881176

1189-
// Call the destructor for the temporary.
11901177
switch (m->getStorageDuration()) {
11911178
case SD_Static:
1192-
case SD_Thread:
1193-
cgf.cgm.errorNYI(e->getSourceRange(),
1194-
"pushTemporaryCleanup: static/thread storage duration");
1195-
return;
1179+
case SD_Thread: {
1180+
CXXDestructorDecl *referenceTemporaryDtor = nullptr;
1181+
if (const clang::RecordType *rt = e->getType()
1182+
->getBaseElementTypeUnsafe()
1183+
->getAs<clang::RecordType>()) {
1184+
// Get the destructor for the reference temporary.
1185+
if (const auto *classDecl = dyn_cast<CXXRecordDecl>(
1186+
rt->getOriginalDecl()->getDefinitionOrSelf())) {
1187+
if (!classDecl->hasTrivialDestructor())
1188+
referenceTemporaryDtor =
1189+
classDecl->getDefinitionOrSelf()->getDestructor();
1190+
}
1191+
}
1192+
1193+
if (!referenceTemporaryDtor)
1194+
return;
1195+
1196+
cgf.cgm.errorNYI(e->getSourceRange(), "pushTemporaryCleanup: static/thread "
1197+
"storage duration with destructors");
1198+
break;
1199+
}
11961200

11971201
case SD_FullExpression:
11981202
cgf.pushDestroy(NormalAndEHCleanup, referenceTemporary, e->getType(),

0 commit comments

Comments
 (0)