[clang] [Clang] Mark this pointer in destructors dead_on_return (PR #166276)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 1 10:53:44 PST 2025


================
@@ -2800,6 +2801,15 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
             .getAsAlign();
     Attrs.addAlignmentAttr(Alignment);
 
+    if (isa_and_nonnull<CXXDestructorDecl>(
+            CalleeInfo.getCalleeDecl().getDecl())) {
+      auto *ClassDecl = dyn_cast<CXXRecordDecl>(
+          CalleeInfo.getCalleeDecl().getDecl()->getDeclContext());
+      if (ClassDecl->getNumBases() == 0 && ClassDecl->getNumVBases() == 0) {
----------------
rnk wrote:

Why do we have to limit this to only destructors of classes with no bases? Whatever the reason (caution, incremental change, etc), comments here would be appreciated.

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


More information about the cfe-commits mailing list