[clang] Always emit complete debug info for types which appear as a member of a standard-layout union. (PR #221615)

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 14 15:55:15 PDT 2026


================
@@ -3244,6 +3244,17 @@ static bool canUseCtorHoming(const CXXRecordDecl *RD) {
       RD->hasConstexprNonCopyMoveConstructor())
     return false;
 
+  // Skip this optimization if this type is standard-layout and is a member of
+  // some standard-layout union in this translation unit. Per the C++ spec, "it
----------------
dwblaikie wrote:

I /believe/ that's not the case - I think Clang does incremental lowering (lowering functions to LLVM IR as they are parsed, rather than in a batch at the end). For insntance, try debugging clang as it compiles this program with debug info enabled:
```
struct t1 { };
void f1(t1) {
}
void f2() {
  return 1;
}
```
Break in canUseCtorHoming, and note that the breakpoint is recached before the diagnostic is hit for the mismatched return in f2.

Not sure what concerns @efriedma-quic has with this situation, but if he's got a moment to expand on it - should be considered.

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


More information about the cfe-commits mailing list