diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -365,7 +365,7 @@ /// Check if type and variable info should be emitted. bool hasReducedDebugInfo() const { - return getDebugInfo() >= codegenoptions::DebugInfoConstructor; + return getDebugInfo() >= codegenoptions::LimitedDebugInfo; } }; diff --git a/clang/include/clang/Basic/DebugInfoOptions.h b/clang/include/clang/Basic/DebugInfoOptions.h --- a/clang/include/clang/Basic/DebugInfoOptions.h +++ b/clang/include/clang/Basic/DebugInfoOptions.h @@ -34,15 +34,12 @@ /// (-gline-tables-only). DebugLineTablesOnly, - /// Limit generated debug info for classes to reduce size. This emits class - /// type info only where the constructor is emitted, if it is a class that - /// has a constructor. - DebugInfoConstructor, - /// Limit generated debug info to reduce size (-fno-standalone-debug). This /// emits forward decls for types that could be replaced with forward decls in /// the source code. For dynamic C++ classes type info is only emitted into - /// the module that contains the classe's vtable. + /// the module that contains the classe's vtable. For classes with + /// nontrivial, user-defined constructors, the type info is only emitted in + /// the module that contains a constructor. LimitedDebugInfo, /// Generate complete debug info. 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 @@ -592,7 +592,6 @@ case codegenoptions::DebugDirectivesOnly: EmissionKind = llvm::DICompileUnit::DebugDirectivesOnly; break; - case codegenoptions::DebugInfoConstructor: case codegenoptions::LimitedDebugInfo: case codegenoptions::FullDebugInfo: EmissionKind = llvm::DICompileUnit::FullDebug; @@ -1689,9 +1688,8 @@ if (CGM.getLangOpts().Optimize) SPFlags |= llvm::DISubprogram::SPFlagOptimized; - // In this debug mode, emit type info for a class when its constructor type - // info is emitted. - if (DebugKind == codegenoptions::DebugInfoConstructor) + // Emit class type info when its constructor is emitted. + if (DebugKind == codegenoptions::LimitedDebugInfo) if (const CXXConstructorDecl *CD = dyn_cast(Method)) completeClass(CD->getParent()); @@ -2280,10 +2278,10 @@ !isClassOrMethodDLLImport(CXXDecl)) return true; - // 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. - if (DebugKind == codegenoptions::DebugInfoConstructor && + // Only emit complete debug info for a class with a user-defined constructor + // when its constructor is emitted. Skip this optimization if the class or + // any of its methods are marked dllimport. + if (DebugKind == codegenoptions::LimitedDebugInfo && !CXXDecl->isLambda() && !CXXDecl->hasConstexprNonCopyMoveConstructor() && !isClassOrMethodDLLImport(CXXDecl)) for (const auto *Ctor : CXXDecl->ctors()) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -1004,9 +1004,6 @@ case codegenoptions::DebugLineTablesOnly: CmdArgs.push_back("-debug-info-kind=line-tables-only"); break; - case codegenoptions::DebugInfoConstructor: - CmdArgs.push_back("-debug-info-kind=constructor"); - break; case codegenoptions::LimitedDebugInfo: CmdArgs.push_back("-debug-info-kind=limited"); break; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -727,7 +727,6 @@ llvm::StringSwitch(A->getValue()) .Case("line-tables-only", codegenoptions::DebugLineTablesOnly) .Case("line-directives-only", codegenoptions::DebugDirectivesOnly) - .Case("constructor", codegenoptions::DebugInfoConstructor) .Case("limited", codegenoptions::LimitedDebugInfo) .Case("standalone", codegenoptions::FullDebugInfo) .Default(~0U); 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 @@ -1,4 +1,4 @@ -// RUN: %clang -cc1 -debug-info-kind=constructor -emit-llvm %s -o - | FileCheck %s +// RUN: %clang -cc1 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s // CHECK-DAG: !DICompositeType(tag: DW_TAG_structure_type, name: "A"{{.*}}DIFlagTypePassByValue struct A { diff --git a/clang/test/CodeGenCXX/debug-lambda-this.cpp b/clang/test/CodeGenCXX/debug-lambda-this.cpp --- a/clang/test/CodeGenCXX/debug-lambda-this.cpp +++ b/clang/test/CodeGenCXX/debug-lambda-this.cpp @@ -1,8 +1,6 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -debug-info-kind=limited | FileCheck %s struct D { - D(); - D(const D&); int x; int d(int x); }; @@ -15,7 +13,7 @@ // CHECK: ![[D:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "D", // CHECK: ![[POINTER:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[D]], size: 64) // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "this", -// CHECK-SAME: line: 11 +// CHECK-SAME: line: 9 // CHECK-SAME: baseType: ![[POINTER]] // CHECK-SAME: size: 64 // CHECK-NOT: offset: 0 diff --git a/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp --- a/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp +++ b/lldb/test/Shell/SymbolFile/PDB/Inputs/ClassLayoutTest.cpp @@ -106,6 +106,7 @@ int main() { MemberTest::Base B1; B1.Get(); + MemberTest::Class C1; MemberTest::Class::StaticMemberFunc(1, 10, 2); return 0; }