aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-01-06 19:22:19 +0000
committerAdrian Prantl <aprantl@apple.com>2016-01-06 19:22:19 +0000
commitb3b821f1df5a2820b117b2b6c65bbb4620972675 (patch)
tree2e38876ff5c300ecb7f621a89d3e6be661d94c43 /clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
parentd9be7530490647e4128df8b2fa90e2e65ae813b1 (diff)
downloadllvm-b3b821f1df5a2820b117b2b6c65bbb4620972675.zip
llvm-b3b821f1df5a2820b117b2b6c65bbb4620972675.tar.gz
llvm-b3b821f1df5a2820b117b2b6c65bbb4620972675.tar.bz2
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
Diffstat (limited to 'clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp')
-rw-r--r--clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index b397eb3..f385e53 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -59,8 +59,10 @@ class PCHContainerGenerator : public ASTConsumer {
struct DebugTypeVisitor : public RecursiveASTVisitor<DebugTypeVisitor> {
clang::CodeGen::CGDebugInfo &DI;
ASTContext &Ctx;
- DebugTypeVisitor(clang::CodeGen::CGDebugInfo &DI, ASTContext &Ctx)
- : DI(DI), Ctx(Ctx) {}
+ bool SkipTagDecls;
+ DebugTypeVisitor(clang::CodeGen::CGDebugInfo &DI, ASTContext &Ctx,
+ bool SkipTagDecls)
+ : DI(DI), Ctx(Ctx), SkipTagDecls(SkipTagDecls) {}
/// Determine whether this type can be represented in DWARF.
static bool CanRepresent(const Type *Ty) {
@@ -75,6 +77,12 @@ class PCHContainerGenerator : public ASTConsumer {
}
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);
if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
DI.getOrCreateStandaloneType(QualTy, D->getLocation());
@@ -165,7 +173,7 @@ public:
// Collect debug info for all decls in this group.
for (auto *I : D)
if (!I->isFromASTFile()) {
- DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx);
+ DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, true);
DTV.TraverseDecl(I);
}
return true;
@@ -179,6 +187,11 @@ public:
if (Diags.hasErrorOccurred())
return;
+ if (D->isFromASTFile())
+ return;
+
+ DebugTypeVisitor DTV(*Builder->getModuleDebugInfo(), *Ctx, false);
+ DTV.TraverseDecl(D);
Builder->UpdateCompletedType(D);
}