[clang] [DebugInfo] Ignore delegating constructors in constructor homing. (PR #218807)
David Blaikie via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 1 10:48:06 PDT 2026
================
@@ -2535,10 +2535,17 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
SPFlags |= llvm::DISubprogram::SPFlagOptimized;
// In this debug mode, emit type info for a class when its constructor type
- // info is emitted.
- if (DebugKind == llvm::codegenoptions::DebugInfoConstructor)
- if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(Method))
- completeUnusedClass(*CD->getParent());
+ // info is emitted. Delegating constructors are ignored because the target
+ // constructor's definition will emit the type info.
+ if (DebugKind == llvm::codegenoptions::DebugInfoConstructor) {
+ if (const auto *CD = dyn_cast<CXXConstructorDecl>(Method)) {
+ const FunctionDecl *Def = nullptr;
+ if (CD->isDefined(Def) &&
+ !cast<CXXConstructorDecl>(Def)->isDelegatingConstructor()) {
+ completeUnusedClass(*CD->getParent());
+ }
----------------
dwblaikie wrote:
Can we assume this is a definition? I expect the old code was assuming it was a definition, otherwise it wouldn't make senseto emit the class info if we were only emitting a declaration of the function?
```suggestion
if (!cast<CXXConstructorDecl>(CD->getDefinition())->isDelegatingConstructor()) {
completeUnusedClass(*CD->getParent());
}
```
https://github.com/llvm/llvm-project/pull/218807
More information about the cfe-commits
mailing list