Skip to content

Commit

Permalink
[DebugInfo] Fix to ctor homing to ignore classes with trivial ctors.
Browse files Browse the repository at this point in the history
Previously ctor homing was omitting debug info for classes if they
have both trival and nontrivial constructors, but we should only omit debug
info if the class doesn't have any trivial constructors.

retained types list.

bug: https://bugs.llvm.org/show_bug.cgi?id=46537

Differential Revision: https://reviews.llvm.org/D84870
  • Loading branch information
amykhuang committed Jul 30, 2020
1 parent 8224c50 commit f71deb4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
13 changes: 10 additions & 3 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Expand Up @@ -2296,12 +2296,19 @@ static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
// In constructor debug mode, only emit debug info for a class when its
// constructor is emitted. Skip this optimization if the class or any of
// its methods are marked dllimport.
//
// This applies to classes that don't have any trivial constructors and have
// at least one constructor.
if (DebugKind == codegenoptions::DebugInfoConstructor &&
!CXXDecl->isLambda() && !CXXDecl->hasConstexprNonCopyMoveConstructor() &&
!isClassOrMethodDLLImport(CXXDecl))
!isClassOrMethodDLLImport(CXXDecl)) {
if (CXXDecl->ctors().empty())
return false;
for (const auto *Ctor : CXXDecl->ctors())
if (Ctor->isUserProvided())
return true;
if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
return false;
return true;
}

TemplateSpecializationKind Spec = TSK_Undeclared;
if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
Expand Down
7 changes: 7 additions & 0 deletions clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
Expand Up @@ -24,3 +24,10 @@ D::D() {}
struct E {
constexpr E(){};
} TestE;

// CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "F"{{.*}}DIFlagTypePassByValue
struct F {
F() = default;
F(int) {}
int i;
} TestF;

0 comments on commit f71deb4

Please sign in to comment.