[llvm] r194728 - DwarfCompileUnit::getOrCreateContext: Return the compile unit DIE rather than null.
David Blaikie
dblaikie at gmail.com
Thu Nov 14 13:24:35 PST 2013
Author: dblaikie
Date: Thu Nov 14 15:24:34 2013
New Revision: 194728
URL: http://llvm.org/viewvc/llvm-project?rev=194728&view=rev
Log:
DwarfCompileUnit::getOrCreateContext: Return the compile unit DIE rather than null.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=194728&r1=194727&r2=194728&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Thu Nov 14 15:24:34 2013
@@ -863,6 +863,8 @@ void CompileUnit::addTemplateParams(DIE
/// 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(con
// 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(D
// 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::getOrCreateSubprogramD
// 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::createGlobalVariableDI
// 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::getOrCreateStaticMembe
// 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)
More information about the llvm-commits
mailing list