[PATCH] D144931: DebugInfo: Disable ctor homing for types with only deleted (non copy/move) ctors

David Blaikie via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 27 17:25:38 PST 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd8a1a559f300: DebugInfo: Disable ctor homing for types with only deleted (non copy/move) ctors (authored by dblaikie).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144931/new/

https://reviews.llvm.org/D144931

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-limited-ctor.cpp


Index: clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -68,6 +68,21 @@
 };
 void f(K k) {}
 
+// CHECK-DAG: !DICompositeType({{.*}}name: "DeletedCtors",{{.*}}DIFlagTypePassBy
+struct NonTrivial {
+  NonTrivial();
+};
+struct DeletedCtors {
+  DeletedCtors() = delete;
+  DeletedCtors(const DeletedCtors &) = default;
+  void f1();
+  NonTrivial t;
+};
+
+const NonTrivial &f(const DeletedCtors &D) {
+  return D.t;
+}
+
 // Test that we don't use constructor homing on lambdas.
 // CHECK-DAG: ![[L:.*]] ={{.*}}!DISubprogram({{.*}}name: "L"
 // CHECK-DAG: !DICompositeType({{.*}}scope: ![[L]], {{.*}}DIFlagTypePassByValue
@@ -89,3 +104,4 @@
 }
 
 // ITANIUM-DAG: !DICompositeType({{.*}}name: "VTableAndCtor", {{.*}}flags: DIFlagFwdDecl
+
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2489,9 +2489,18 @@
   if (isClassOrMethodDLLImport(RD))
     return false;
 
-  return !RD->isLambda() && !RD->isAggregate() &&
-         !RD->hasTrivialDefaultConstructor() &&
-         !RD->hasConstexprNonCopyMoveConstructor();
+  if (RD->isLambda() || RD->isAggregate() ||
+      RD->hasTrivialDefaultConstructor() ||
+      RD->hasConstexprNonCopyMoveConstructor())
+    return false;
+
+  for (const CXXConstructorDecl *Ctor : RD->ctors()) {
+    if (Ctor->isCopyOrMoveConstructor())
+      continue;
+    if (!Ctor->isDeleted())
+      return true;
+  }
+  return false;
 }
 
 static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144931.500981.patch
Type: text/x-patch
Size: 1764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230228/015e21a4/attachment.bin>


More information about the cfe-commits mailing list