[clang] [CIR] Implement Statement Expressions (PR #153677)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 15 10:10:39 PDT 2025


================
@@ -1178,11 +1178,11 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf,
                                         ->getBaseElementTypeUnsafe()
                                         ->getAs<clang::RecordType>()) {
     // Get the destructor for the reference temporary.
-    auto *classDecl =
-        cast<CXXRecordDecl>(rt->getOriginalDecl()->getDefinitionOrSelf());
-    if (!classDecl->hasTrivialDestructor())
-      referenceTemporaryDtor =
-          classDecl->getDefinitionOrSelf()->getDestructor();
+    if (const auto *classDecl = dyn_cast<CXXRecordDecl>(
+            rt->getOriginalDecl()->getDefinitionOrSelf())) {
+      if (!classDecl->hasTrivialDestructor())
+        referenceTemporaryDtor = classDecl->getDestructor();
----------------
andykaylor wrote:

Does this fix the case you mentioned in your comment below about the destructor being called?

https://github.com/llvm/llvm-project/pull/153677


More information about the cfe-commits mailing list