diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2289,14 +2289,15 @@ isClassOrMethodDLLImport(RD)) return false; - if (RD->ctors().empty()) - return false; - - for (const auto *Ctor : RD->ctors()) + bool hasCtor = false; + for (const auto *Ctor : RD->ctors()) { if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor()) return false; + if (!Ctor->isCopyOrMoveConstructor()) + hasCtor = true; + } - return true; + return hasCtor; } static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind, diff --git a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp --- a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp +++ b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp @@ -31,3 +31,16 @@ F(int) {} int i; } TestF; + +// CHECK-DAG: ![[G:.*]] ={{.*}}!DICompositeType({{.*}}name: "G"{{.*}}DIFlagTypePassByValue +// CHECK-DAG: !DICompositeType({{.*}}scope: ![[G]], {{.*}}DIFlagTypePassByValue +// The inner struct only has copy/move constructors so it shouldn't be subject +// to constructor homing. +struct G { + G() : g_(0) {} + struct { + int g_; + }; +} TestG; + +