================
@@ -27,6 +27,39 @@ struct E {
   constexpr E(){};
 } TestE;
 
+// Defined delegating constructor where delegated constructor is not defined
+// should not emit full debug info.
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"Delegating"{{.*}}flags: DIFlagFwdDecl
+struct Delegating {
+  Delegating() : Delegating(42) {}
+  Delegating(int);
+} TestDelegating;
+
+// Defined delegating constructor where delegated constructor is defined should
+// emit full debug info.
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"DelegatingToDefined"{{.*}}DIFlagTypePassByValue
+struct DelegatingToDefined {
+  DelegatingToDefined() : DelegatingToDefined(42) {}
+  DelegatingToDefined(int) {}
+} TestDelegatingToDefined;
+
+// Defined out-of-line delegating constructor where delegated constructor is
+// defined should emit full debug info.
+// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: 
"DelegatingOutOfLine"{{.*}}DIFlagTypePassByValue
+struct DelegatingOutOfLine {
+  DelegatingOutOfLine();
+  DelegatingOutOfLine(int) {}
+};
+DelegatingOutOfLine d;
+DelegatingOutOfLine::DelegatingOutOfLine() : DelegatingOutOfLine(42) {}
----------------
dwblaikie wrote:

> A declared-but-not-defined delegating constructor looks just like a 
> non-delegating constructor. You can't tell if a constructor is delegating 
> until you see its definition.

Yep, that'd be my understanding/expectation.

> If you mean the constructor that is being delegated to (not sure how to word 
> this in English haha), the `Delegating` test struct has an inline delegating 
> ctor which delegates to a declared-but-not-defined ctor (no debug info). The 
> `DelegatingToDefined` delegates to an inlined ctor.
> 
> I've added another test case `DelegatingToOutOfLine`, which is an inline 
> delegating ctor delegating to an out-of-line ctor. It verifies that debug 
> info should be emitted.

I'd have expected debug info to /not/ be emitted in this case, though? Oh, 
depending on whether theout-of-line ctor is defined or not. That's the case I'm 
curious about - a situation where the delegating ctor is emitted (probably 
doesn't matter if the ctor is inline or not - maybe it'd be easier/clearer if 
these test cases didn't use inline definitions?) but the ctor it is delegating 
to is not emitted (because it's not defined in this translation unit at all) - 
in which case I'd expect the delegated-to ctor to be a valid home for the type, 
so the TU where the delegating ctor is emitted would /not/ act as a home for 
the type.




https://github.com/llvm/llvm-project/pull/218807
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to