[clang] Revert "[DebugInfo] Ignore undefined constexpr constructors in constructor homing." (PR #221566)

Avi Kivity via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 6 11:01:35 PDT 2026


================
@@ -27,12 +27,23 @@ struct E {
   constexpr E(){};
 } TestE;
 
-// Declared but not defined constexpr constructor should not emit full debug info..
-// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "DeclaredConstexpr"{{.*}}flags: DIFlagFwdDecl
+// A constexpr constructor that is only declared here may still be defined
+// elsewhere and called, so it cannot be relied on to home the type.
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "DeclaredConstexpr"{{.*}}DIFlagTypePassByValue
 struct DeclaredConstexpr {
   constexpr DeclaredConstexpr();
 } TestDeclaredConstexpr;
 
+// A declared-only constexpr constructor that is never odr-used need not be
+// defined anywhere in the program, so nothing would ever emit the definition
+// of the type - but the type is still required to be complete here.
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "ConstexprDeclaredOnly"{{.*}}DIFlagTypePassByValue
+struct ConstexprDeclaredOnly {
+  unsigned long v;
+  constexpr ConstexprDeclaredOnly(unsigned long t);
----------------
avikivity wrote:

I feel your frustration, but I don't see a way out (except for rewriting the entire world in Rust)

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


More information about the cfe-commits mailing list