================
@@ -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:
> If you declare a constexpr constructor, then in order to construct this type,
> you must invoke this constructor, right? Even if you call it from a
> non-constexpr context, the program won't link unless the constructor is
> defined somewhere.
Isn't this true for non-constexpr constructors are well?
I now understand better the original patch, which wants whoever invokes the
constructor to emit the debug information. But something isn't working.
>
> There is no context that I can think of that would allow you to construct
> this type through this constructor without being able to see the constructors
> definition (which would opt the TU out of ctor homing), and without the
> constructor defined elsewhere (which would opt the defining TU out of ctor
> homing).
>
> The method below, in a real program, could never be invoked, unless you do
> something like `reinterpret_cast` memory constructed as some other type to
> `ConstexprDeclaredOnly`, which is UB (by my understanding).
My original reproducer does call the constructor.
https://github.com/llvm/llvm-project/pull/221566
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits