summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2016-02-23 19:10:16 +0000
committerHans Wennborg <hans@hanshq.net>2016-02-23 19:10:16 +0000
commit8a118b63d84905de8a3a925b007758d511dc1d08 (patch)
treed8d804425374541a0872711226ad2300f989d6cd /clang/lib/CodeGen/CGDebugInfo.cpp
parent558995c9671d094a1e405084a181c9eddab04ec8 (diff)
downloadbcm5719-llvm-8a118b63d84905de8a3a925b007758d511dc1d08.tar.gz
bcm5719-llvm-8a118b63d84905de8a3a925b007758d511dc1d08.zip
Revert r261634 "Supporting all entities declared in lexical scope in LLVM debug info." and r261657
r261634 and r261633 seems to have caused PR26715. r261657 depends on the former two. llvm-svn: 261670
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp59
1 files changed, 17 insertions, 42 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index a0fff814e47..52bd805b81c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -831,18 +831,15 @@ llvm::DIType *CGDebugInfo::CreateType(const TemplateSpecializationType *Ty,
llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
llvm::DIFile *Unit) {
- TypedefNameDecl *TD = Ty->getDecl();
// We don't set size information, but do specify where the typedef was
// declared.
- SourceLocation Loc = TD->getLocation();
-
- llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));
+ SourceLocation Loc = Ty->getDecl()->getLocation();
// Typedefs are derived from some other type.
return DBuilder.createTypedef(
getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
- TDContext);
+ getDeclContextDescriptor(Ty->getDecl()));
}
llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,
@@ -1475,23 +1472,6 @@ llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
return T;
}
-void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {
- assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&
- "D is already mapped to lexical block scope");
- if (!LexicalBlockStack.empty())
- LexicalBlockMap[&D] = LexicalBlockStack.back();
-}
-
-llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,
- QualType Ty) {
- auto I = LexicalBlockMap.find(&D);
- if (I != LexicalBlockMap.end()) {
- RetainedTypes.push_back(Ty.getAsOpaquePtr());
- return I->second;
- }
- return getDeclContextDescriptor(cast<Decl>(&D));
-}
-
void CGDebugInfo::completeType(const EnumDecl *ED) {
if (DebugKind <= codegenoptions::DebugLineTablesOnly)
return;
@@ -2071,22 +2051,24 @@ llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType *Ty) {
// If this is just a forward declaration, construct an appropriately
// marked node and just return it.
if (isImportedFromModule || !ED->getDefinition()) {
- // Note that it is possible for enums to be created as part of
- // their own declcontext. In this case a FwdDecl will be created
- // twice. This doesn't cause a problem because both FwdDecls are
- // entered into the ReplaceMap: finalize() will replace the first
- // FwdDecl with the second and then replace the second with
- // complete type.
- llvm::DIScope *EDContext = getDeclContextDescriptor(ED);
llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
+
+ // It is possible for enums to be created as part of their own
+ // declcontext. We need to cache a placeholder to avoid the type being
+ // created twice before hitting the cache.
llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
unsigned Line = getLineNumber(ED->getLocation());
StringRef EDName = ED->getName();
llvm::DIType *RetTy = DBuilder.createReplaceableCompositeType(
- llvm::dwarf::DW_TAG_enumeration_type, EDName, EDContext, DefUnit, Line,
- 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName);
+ llvm::dwarf::DW_TAG_enumeration_type, EDName, TmpContext.get(), DefUnit,
+ Line, 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName);
+
+ // Cache the enum type so it is available when building the declcontext
+ // and replace the declcontect with the real thing.
+ TypeCache[Ty].reset(RetTy);
+ TmpContext->replaceAllUsesWith(getDeclContextDescriptor(ED));
ReplaceMap.emplace_back(
std::piecewise_construct, std::make_tuple(Ty),
@@ -2121,7 +2103,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) {
llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());
unsigned Line = getLineNumber(ED->getLocation());
- llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 0));
+ llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);
llvm::DIType *ClassTy =
ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;
return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,
@@ -2382,7 +2364,7 @@ llvm::DICompositeType *CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
unsigned Line = getLineNumber(RD->getLocation());
StringRef RDName = getClassName(RD);
- llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0));
+ llvm::DIScope *RDContext = getDeclContextDescriptor(RD);
// If we ended up creating the type during the context chain construction,
// just return that.
@@ -2529,15 +2511,8 @@ void CGDebugInfo::collectVarDeclProps(const VarDecl *VD, llvm::DIFile *&Unit,
if (DC->isRecord())
DC = CGM.getContext().getTranslationUnitDecl();
- if (VD->isStaticLocal()) {
- // Get context for static locals (that are technically globals) the same way
- // we do for "local" locals -- by using current lexical block.
- assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
- VDContext = LexicalBlockStack.back();
- } else {
- llvm::DIScope *Mod = getParentModuleOrNull(VD);
- VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);
- }
+ llvm::DIScope *Mod = getParentModuleOrNull(VD);
+ VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);
}
llvm::DISubprogram *
OpenPOWER on IntegriCloud