summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-11-14 21:24:34 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-11-14 21:24:34 +0000
commit8c0fecc39fe7f0928a7592104b4419022ad4b54e (patch)
tree5daecfb3f49c2046e789d6882b51044ca58c0c46
parentf4837be7c1d8f2a9e90100e849b148eb86a2d27e (diff)
downloadllvm-8c0fecc39fe7f0928a7592104b4419022ad4b54e.tar.gz
llvm-8c0fecc39fe7f0928a7592104b4419022ad4b54e.tar.bz2
llvm-8c0fecc39fe7f0928a7592104b4419022ad4b54e.tar.xz
DwarfCompileUnit::getOrCreateContext: Return the compile unit DIE rather than null.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194728 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 9fd0f02f68..857b41415a 100644
--- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -863,6 +863,8 @@ void CompileUnit::addTemplateParams(DIE &Buffer, DIArray TParams) {
/// getOrCreateContextDIE - Get context owner's DIE.
DIE *CompileUnit::getOrCreateContextDIE(DIScope Context) {
+ if (!Context || Context.isFile())
+ return getCUDie();
if (Context.isType())
return getOrCreateTypeDIE(DIType(Context));
if (Context.isNameSpace())
@@ -882,8 +884,6 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE.
DIE *ContextDIE = getOrCreateContextDIE(resolve(Ty.getContext()));
- if (!ContextDIE)
- ContextDIE = CUDie.get();
DIE *TyDIE = getDIE(Ty);
if (TyDIE)
@@ -1355,10 +1355,6 @@ DIE *CompileUnit::getOrCreateNameSpace(DINameSpace NS) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE.
DIE *ContextDIE = getOrCreateContextDIE(NS.getContext());
- if (!ContextDIE)
- // If the context is null, DIE should belong to the CU we call construct
- // function on.
- ContextDIE = CUDie.get();
DIE *NDie = getDIE(NS);
if (NDie)
@@ -1381,8 +1377,6 @@ DIE *CompileUnit::getOrCreateSubprogramDIE(DISubprogram SP) {
// such construction creates the DIE (as is the case for member function
// declarations).
DIE *ContextDIE = getOrCreateContextDIE(resolve(SP.getContext()));
- if (!ContextDIE)
- ContextDIE = CUDie.get();
DIE *SPDie = getDIE(SP);
if (SPDie)
@@ -1541,8 +1535,6 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) {
// Construct the context before querying for the existence of the DIE in
// case such construction creates the DIE.
DIE *ContextDIE = getOrCreateContextDIE(GVContext);
- if (!ContextDIE)
- ContextDIE = CUDie.get();
// Add to map.
VariableDIE = createAndAddDIE(GV.getTag(), *ContextDIE, N);
@@ -1913,7 +1905,8 @@ DIE *CompileUnit::getOrCreateStaticMemberDIE(const DIDerivedType DT) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE.
DIE *ContextDIE = getOrCreateContextDIE(resolve(DT.getContext()));
- assert(ContextDIE && "Static member should belong to a non-CU context.");
+ assert(dwarf::isType(ContextDIE->getTag()) &&
+ "Static member should belong to a type.");
DIE *StaticMemberDIE = getDIE(DT);
if (StaticMemberDIE)