forked from OSchip/llvm-project
Module debugging: Defer emitting tag types until their definition
was visited and all decls have been merged. We only get a single chance to emit the types for virtual classes because CGDebugInfo::completeRequiredType() categorically doesn't complete them. llvm-svn: 256962
This commit is contained in:
parent
d9be753049
commit
b3b821f1df
|
@ -59,8 +59,10 @@ class PCHContainerGenerator : public ASTConsumer {
|
||||||
struct DebugTypeVisitor : public RecursiveASTVisitor<DebugTypeVisitor> {
|
struct DebugTypeVisitor : public RecursiveASTVisitor<DebugTypeVisitor> {
|
||||||
clang::CodeGen::CGDebugInfo &DI;
|
clang::CodeGen::CGDebugInfo &DI;
|
||||||
ASTContext &Ctx;
|
ASTContext &Ctx;
|
||||||
DebugTypeVisitor(clang::CodeGen::CGDebugInfo &DI, ASTContext &Ctx)
|
bool SkipTagDecls;
|
||||||
: DI(DI), Ctx(Ctx) {}
|
DebugTypeVisitor(clang::CodeGen::CGDebugInfo &DI, ASTContext &Ctx,
|
||||||
|
bool SkipTagDecls)
|
||||||
|
: DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
|
||||||
|
|
||||||
/// Determine whether this type can be represented in DWARF.
|
/// Determine whether this type can be represented in DWARF.
|
||||||
static bool CanRepresent(const Type *Ty) {
|
static bool CanRepresent(const Type *Ty) {
|
||||||
|
@ -75,6 +77,12 @@ class PCHContainerGenerator : public ASTConsumer {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VisitTypeDecl(TypeDecl *D) {
|
bool VisitTypeDecl(TypeDecl *D) {
|
||||||
|
// TagDecls may be deferred until after all decls have been merged and we
|
||||||
|
// know the complete type. Pure forward declarations will be skipped, but
|
||||||
|
// they don't need to be emitted into the module anyway.
|
||||||
|
if (SkipTagDecls && isa<TagDecl>(D))
|
||||||
|
return true;
|
||||||
|
|
||||||
QualType QualTy = Ctx.getTypeDeclType(D);
|
QualType QualTy = Ctx.getTypeDeclType(D);
|
||||||
if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
|
if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
|
||||||
DI.getOrCreateStandaloneType(QualTy, D->getLocation());
|
DI.getOrCreateStandaloneType(QualTy, D->getLocation());
|
||||||
|
@ -165,7 +173,7 @@ public:
|
||||||
// Collect debug info for all decls in this group.
|
// Collect debug info for all decls in this group.
|
||||||
for (auto *I : D)
|
for (auto *I : D)
|
||||||
if (!I->isFromASTFile()) {
|
if (!I->isFromASTFile()) {
|
||||||
DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
|
DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
|
||||||
DTV.TraverseDecl(I);
|
DTV.TraverseDecl(I);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -179,6 +187,11 @@ public:
|
||||||
if (Diags.hasErrorOccurred())
|
if (Diags.hasErrorOccurred())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (D->isFromASTFile())
|
||||||
|
return;
|
||||||
|
|
||||||
|
DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
|
||||||
|
DTV.TraverseDecl(D);
|
||||||
Builder->UpdateCompletedType(D);
|
Builder->UpdateCompletedType(D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,3 +50,9 @@ namespace DebugCXX {
|
||||||
typedef A<void> B;
|
typedef A<void> B;
|
||||||
void foo(B) {}
|
void foo(B) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Virtual class with a forward declaration.
|
||||||
|
class FwdVirtual;
|
||||||
|
class FwdVirtual {
|
||||||
|
virtual ~FwdVirtual() {}
|
||||||
|
};
|
||||||
|
|
|
@ -7,13 +7,11 @@
|
||||||
// RUN: rm -rf %t
|
// RUN: rm -rf %t
|
||||||
// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -x objective-c++ -std=c++11 -debug-info-kind=limited -fmodules -fmodule-format=obj -fimplicit-module-maps -DMODULES -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o %t.ll -mllvm -debug-only=pchcontainer &>%t-mod.ll
|
||||||
// RUN: cat %t-mod.ll | FileCheck %s
|
// RUN: cat %t-mod.ll | FileCheck %s
|
||||||
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-NEG %s
|
|
||||||
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
|
// RUN: cat %t-mod.ll | FileCheck --check-prefix=CHECK-DWO %s
|
||||||
|
|
||||||
// PCH:
|
// PCH:
|
||||||
// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -x c++ -std=c++11 -emit-pch -fmodule-format=obj -I %S/Inputs -o %t.pch %S/Inputs/DebugCXX.h -mllvm -debug-only=pchcontainer &>%t-pch.ll
|
||||||
// RUN: cat %t-pch.ll | FileCheck %s
|
// RUN: cat %t-pch.ll | FileCheck %s
|
||||||
// RUN: cat %t-pch.ll | FileCheck --check-prefix=CHECK-NEG %s
|
|
||||||
|
|
||||||
#ifdef MODULES
|
#ifdef MODULES
|
||||||
@import DebugCXX;
|
@import DebugCXX;
|
||||||
|
@ -23,22 +21,32 @@
|
||||||
// CHECK-SAME: isOptimized: false,
|
// CHECK-SAME: isOptimized: false,
|
||||||
// CHECK-SAME-NOT: splitDebugFilename:
|
// CHECK-SAME-NOT: splitDebugFilename:
|
||||||
// CHECK-DWO: dwoId:
|
// CHECK-DWO: dwoId:
|
||||||
|
|
||||||
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum"
|
// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "Enum"
|
||||||
// CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
|
// CHECK-SAME: identifier: "_ZTSN8DebugCXX4EnumE")
|
||||||
// CHECK: !DINamespace(name: "DebugCXX"
|
// CHECK: !DINamespace(name: "DebugCXX"
|
||||||
|
|
||||||
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
|
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
|
||||||
// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
|
// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
|
||||||
|
|
||||||
// CHECK: !DICompositeType(tag: DW_TAG_class_type,
|
// CHECK: !DICompositeType(tag: DW_TAG_class_type,
|
||||||
// CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >"
|
// CHECK-SAME: name: "Template<int, DebugCXX::traits<int> >"
|
||||||
// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
|
// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIiNS_6traitsIiEEEE")
|
||||||
|
|
||||||
|
// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>"
|
||||||
|
// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
|
||||||
|
|
||||||
// CHECK: !DICompositeType(tag: DW_TAG_class_type,
|
// CHECK: !DICompositeType(tag: DW_TAG_class_type,
|
||||||
// CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >"
|
// CHECK-SAME: name: "Template<float, DebugCXX::traits<float> >"
|
||||||
// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
|
// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
|
||||||
// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>"
|
|
||||||
// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
|
// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "FwdVirtual"
|
||||||
|
// CHECK-SAME: elements:
|
||||||
|
// CHECK-SAME: identifier: "_ZTS10FwdVirtual")
|
||||||
|
// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "_vptr$FwdVirtual"
|
||||||
|
|
||||||
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
|
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstatiation"
|
||||||
// no mangled name here yet.
|
// no mangled name here yet.
|
||||||
|
|
||||||
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
|
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
|
||||||
// no mangled name here yet.
|
// no mangled name here yet.
|
||||||
|
|
||||||
// CHECK-NEG-NOT: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE"
|
|
||||||
|
|
Loading…
Reference in New Issue