Do not require variable debug info nodes to have a compile unit.

For implicit decls like "self" and "_cmd" in ObjC, these decls
should not have a location.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70964 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-05-05 04:55:56 +00:00
parent bef60d3804
commit e3f6cea9e9
2 changed files with 25 additions and 22 deletions

View File

@ -295,7 +295,7 @@ bool DIGlobalVariable::Verify() const {
return false; return false;
DICompileUnit CU = getCompileUnit(); DICompileUnit CU = getCompileUnit();
if (!CU.Verify()) if (!CU.isNull() && !CU.Verify())
return false; return false;
DIType Ty = getType(); DIType Ty = getType();
@ -320,7 +320,6 @@ bool DIVariable::Verify() const {
if (!Ty.Verify()) if (!Ty.Verify())
return false; return false;
return true; return true;
} }

View File

@ -1524,11 +1524,13 @@ private:
/// AddSourceLine - Add location information to specified debug information /// AddSourceLine - Add location information to specified debug information
/// entry. /// entry.
void AddSourceLine(DIE *Die, const DIVariable *V) { void AddSourceLine(DIE *Die, const DIVariable *V) {
unsigned FileID = 0; // If there is no compile unit specified, don't add a line #.
if (V->getCompileUnit().isNull())
return;
unsigned Line = V->getLineNumber(); unsigned Line = V->getLineNumber();
CompileUnit *Unit = FindCompileUnit(V->getCompileUnit()); unsigned FileID = FindCompileUnit(V->getCompileUnit()).getID();
FileID = Unit->getID(); assert(FileID && "Invalid file id");
assert (FileID && "Invalid file id");
AddUInt(Die, DW_AT_decl_file, 0, FileID); AddUInt(Die, DW_AT_decl_file, 0, FileID);
AddUInt(Die, DW_AT_decl_line, 0, Line); AddUInt(Die, DW_AT_decl_line, 0, Line);
} }
@ -1536,24 +1538,25 @@ private:
/// AddSourceLine - Add location information to specified debug information /// AddSourceLine - Add location information to specified debug information
/// entry. /// entry.
void AddSourceLine(DIE *Die, const DIGlobal *G) { void AddSourceLine(DIE *Die, const DIGlobal *G) {
unsigned FileID = 0; // If there is no compile unit specified, don't add a line #.
if (G->getCompileUnit().isNull())
return;
unsigned Line = G->getLineNumber(); unsigned Line = G->getLineNumber();
CompileUnit *Unit = FindCompileUnit(G->getCompileUnit()); unsigned FileID = FindCompileUnit(G->getCompileUnit()).getID();
FileID = Unit->getID(); assert(FileID && "Invalid file id");
assert (FileID && "Invalid file id");
AddUInt(Die, DW_AT_decl_file, 0, FileID); AddUInt(Die, DW_AT_decl_file, 0, FileID);
AddUInt(Die, DW_AT_decl_line, 0, Line); AddUInt(Die, DW_AT_decl_line, 0, Line);
} }
void AddSourceLine(DIE *Die, const DIType *Ty) { void AddSourceLine(DIE *Die, const DIType *Ty) {
unsigned FileID = 0; // If there is no compile unit specified, don't add a line #.
unsigned Line = Ty->getLineNumber();
DICompileUnit CU = Ty->getCompileUnit(); DICompileUnit CU = Ty->getCompileUnit();
if (CU.isNull()) if (CU.isNull())
return; return;
CompileUnit *Unit = FindCompileUnit(CU);
FileID = Unit->getID(); unsigned Line = Ty->getLineNumber();
assert (FileID && "Invalid file id"); unsigned FileID = FindCompileUnit(CU).getID();
assert(FileID && "Invalid file id");
AddUInt(Die, DW_AT_decl_file, 0, FileID); AddUInt(Die, DW_AT_decl_file, 0, FileID);
AddUInt(Die, DW_AT_decl_line, 0, Line); AddUInt(Die, DW_AT_decl_line, 0, Line);
} }
@ -1953,10 +1956,11 @@ private:
/// FindCompileUnit - Get the compile unit for the given descriptor. /// FindCompileUnit - Get the compile unit for the given descriptor.
/// ///
CompileUnit *FindCompileUnit(DICompileUnit Unit) { CompileUnit &FindCompileUnit(DICompileUnit Unit) const {
CompileUnit *DW_Unit = CompileUnitMap[Unit.getGV()]; DenseMap<Value *, CompileUnit *>::const_iterator I =
assert(DW_Unit && "Missing compile unit."); CompileUnitMap.find(Unit.getGV());
return DW_Unit; assert(I != CompileUnitMap.end() && "Missing compile unit.");
return *I->second;
} }
/// NewDbgScopeVariable - Create a new scope variable. /// NewDbgScopeVariable - Create a new scope variable.
@ -2118,7 +2122,7 @@ private:
// Get the compile unit context. // Get the compile unit context.
CompileUnit *Unit = MainCU; CompileUnit *Unit = MainCU;
if (!Unit) if (!Unit)
Unit = FindCompileUnit(SPD.getCompileUnit()); Unit = &FindCompileUnit(SPD.getCompileUnit());
// Get the subprogram die. // Get the subprogram die.
DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV()); DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV());
@ -2984,7 +2988,7 @@ private:
DIGlobalVariable DI_GV(GV); DIGlobalVariable DI_GV(GV);
CompileUnit *DW_Unit = MainCU; CompileUnit *DW_Unit = MainCU;
if (!DW_Unit) if (!DW_Unit)
DW_Unit = FindCompileUnit(DI_GV.getCompileUnit()); DW_Unit = &FindCompileUnit(DI_GV.getCompileUnit());
// Check for pre-existence. // Check for pre-existence.
DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV.getGV()); DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV.getGV());
@ -3040,7 +3044,7 @@ private:
DISubprogram SP(GV); DISubprogram SP(GV);
CompileUnit *Unit = MainCU; CompileUnit *Unit = MainCU;
if (!Unit) if (!Unit)
Unit = FindCompileUnit(SP.getCompileUnit()); Unit = &FindCompileUnit(SP.getCompileUnit());
// Check for pre-existence. // Check for pre-existence.
DIE *&Slot = Unit->getDieMapSlotFor(GV); DIE *&Slot = Unit->getDieMapSlotFor(GV);