diff options
author | Chris Lattner <sabre@nondot.org> | 2009-05-05 04:55:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-05-05 04:55:56 +0000 |
commit | 88ab97408d8c4041d8bf4a2a5a8c10cae0cd565c (patch) | |
tree | 79c69fe5ac29e838ed31b7011dd5a91095483a59 /lib/CodeGen | |
parent | 4669f7d6ee8f83e171df13736a54eca7a5f0776f (diff) | |
download | external_llvm-88ab97408d8c4041d8bf4a2a5a8c10cae0cd565c.zip external_llvm-88ab97408d8c4041d8bf4a2a5a8c10cae0cd565c.tar.gz external_llvm-88ab97408d8c4041d8bf4a2a5a8c10cae0cd565c.tar.bz2 |
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
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfWriter.cpp | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp index 8ccd380..75686e1 100644 --- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp @@ -1524,11 +1524,13 @@ private: /// AddSourceLine - Add location information to specified debug information /// entry. 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(); - CompileUnit *Unit = FindCompileUnit(V->getCompileUnit()); - FileID = Unit->getID(); - assert (FileID && "Invalid file id"); + unsigned FileID = FindCompileUnit(V->getCompileUnit()).getID(); + assert(FileID && "Invalid file id"); AddUInt(Die, DW_AT_decl_file, 0, FileID); AddUInt(Die, DW_AT_decl_line, 0, Line); } @@ -1536,24 +1538,25 @@ private: /// AddSourceLine - Add location information to specified debug information /// entry. 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(); - CompileUnit *Unit = FindCompileUnit(G->getCompileUnit()); - FileID = Unit->getID(); - assert (FileID && "Invalid file id"); + unsigned FileID = FindCompileUnit(G->getCompileUnit()).getID(); + assert(FileID && "Invalid file id"); AddUInt(Die, DW_AT_decl_file, 0, FileID); AddUInt(Die, DW_AT_decl_line, 0, Line); } void AddSourceLine(DIE *Die, const DIType *Ty) { - unsigned FileID = 0; - unsigned Line = Ty->getLineNumber(); + // If there is no compile unit specified, don't add a line #. DICompileUnit CU = Ty->getCompileUnit(); if (CU.isNull()) return; - CompileUnit *Unit = FindCompileUnit(CU); - FileID = Unit->getID(); - assert (FileID && "Invalid file id"); + + unsigned Line = Ty->getLineNumber(); + unsigned FileID = FindCompileUnit(CU).getID(); + assert(FileID && "Invalid file id"); AddUInt(Die, DW_AT_decl_file, 0, FileID); AddUInt(Die, DW_AT_decl_line, 0, Line); } @@ -1953,10 +1956,11 @@ private: /// FindCompileUnit - Get the compile unit for the given descriptor. /// - CompileUnit *FindCompileUnit(DICompileUnit Unit) { - CompileUnit *DW_Unit = CompileUnitMap[Unit.getGV()]; - assert(DW_Unit && "Missing compile unit."); - return DW_Unit; + CompileUnit &FindCompileUnit(DICompileUnit Unit) const { + DenseMap<Value *, CompileUnit *>::const_iterator I = + CompileUnitMap.find(Unit.getGV()); + assert(I != CompileUnitMap.end() && "Missing compile unit."); + return *I->second; } /// NewDbgScopeVariable - Create a new scope variable. @@ -2118,7 +2122,7 @@ private: // Get the compile unit context. CompileUnit *Unit = MainCU; if (!Unit) - Unit = FindCompileUnit(SPD.getCompileUnit()); + Unit = &FindCompileUnit(SPD.getCompileUnit()); // Get the subprogram die. DIE *SPDie = Unit->getDieMapSlotFor(SPD.getGV()); @@ -2984,7 +2988,7 @@ private: DIGlobalVariable DI_GV(GV); CompileUnit *DW_Unit = MainCU; if (!DW_Unit) - DW_Unit = FindCompileUnit(DI_GV.getCompileUnit()); + DW_Unit = &FindCompileUnit(DI_GV.getCompileUnit()); // Check for pre-existence. DIE *&Slot = DW_Unit->getDieMapSlotFor(DI_GV.getGV()); @@ -3040,7 +3044,7 @@ private: DISubprogram SP(GV); CompileUnit *Unit = MainCU; if (!Unit) - Unit = FindCompileUnit(SP.getCompileUnit()); + Unit = &FindCompileUnit(SP.getCompileUnit()); // Check for pre-existence. DIE *&Slot = Unit->getDieMapSlotFor(GV); |