diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-10-24 00:46:51 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-10-24 00:46:51 +0000 |
commit | 2104bf96271cb1b57e2af817acbdf4db63b4b171 (patch) | |
tree | 1db7c543fd59a87be8368556b771b8bb3161a6fa /lib/CodeGen/CGDebugInfo.cpp | |
parent | 6ee9b0f0e67f15de7bc1b7e9aa919cbf6f558385 (diff) |
Map compilation units using FileEntry pointers instead of
FileIDs. This seems better conceptually and lets the SourceManager
handle details of mapping the location to a file ID.
- In practice, fixes an assert because this code wasn't using
getPhysicalLoc.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58055 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index e1889603ee..89d00aee5e 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -64,7 +64,7 @@ CGDebugInfo::~CGDebugInfo() delete SR; // Free CompileUnitCache. - for (std::map<unsigned, llvm::CompileUnitDesc *>::iterator I + for (std::map<const FileEntry*, llvm::CompileUnitDesc *>::iterator I = CompileUnitCache.begin(); I != CompileUnitCache.end(); ++I) { delete I->second; } @@ -134,15 +134,17 @@ llvm::Value *CGDebugInfo::getValueFor(llvm::DebugInfoDesc *DD) { /// one if necessary. llvm::CompileUnitDesc *CGDebugInfo::getOrCreateCompileUnit(const SourceLocation Loc) { + SourceManager &SM = M->getContext().getSourceManager(); + const FileEntry *FE = SM.getFileEntryForLoc(Loc); // See if this compile unit has been used before. - llvm::CompileUnitDesc *&Slot = CompileUnitCache[Loc.getFileID()]; - if (Slot) return Slot; - + llvm::CompileUnitDesc *&Unit = CompileUnitCache[FE]; + if (Unit) return Unit; + // Create new compile unit. // FIXME: Where to free these? // One way is to iterate over the CompileUnitCache in ~CGDebugInfo. - llvm::CompileUnitDesc *Unit = new llvm::CompileUnitDesc(); + Unit = new llvm::CompileUnitDesc(); // Make sure we have an anchor. if (!CompileUnitAnchor) { @@ -150,8 +152,6 @@ llvm::CompileUnitDesc } // Get source file information. - SourceManager &SM = M->getContext().getSourceManager(); - const FileEntry *FE = SM.getFileEntryForLoc(Loc); const char *FileName, *DirName; if (FE) { FileName = FE->getName(); @@ -173,9 +173,6 @@ llvm::CompileUnitDesc // FIXME: Handle other languages as well. Unit->setLanguage(llvm::dwarf::DW_LANG_C89); - // Update cache. - Slot = Unit; - return Unit; } |