[clang] f71deb4 - [DebugInfo] Fix to ctor homing to ignore classes with trivial ctors.
Amy Huang via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 29 19:55:39 PDT 2020
Author: Amy Huang
Date: 2020-07-29T19:55:20-07:00
New Revision: f71deb43abea588901c083d3e6d6d25371b486ae
URL: https://github.com/llvm/llvm-project/commit/f71deb43abea588901c083d3e6d6d25371b486ae
DIFF: https://github.com/llvm/llvm-project/commit/f71deb43abea588901c083d3e6d6d25371b486ae.diff
LOG: [DebugInfo] Fix to ctor homing to ignore classes with trivial ctors.
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
Added:
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 780e0c692c05..461f2eee965d 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -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))
diff --git a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
index 25b4ebdb54a3..89dd2b16b75b 100644
--- a/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
+++ b/clang/test/CodeGenCXX/debug-info-limited-ctor.cpp
@@ -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;
More information about the cfe-commits
mailing list