diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-10-17 23:05:28 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-10-17 23:05:28 +0000 |
commit | 44d798d9763bc32aaf49fe7c10d604845f4b6685 (patch) | |
tree | 0449634445ecb9b39e83cb399e8b97656b9f50bd /lib/CodeGen/AsmPrinter/DwarfDebug.cpp | |
parent | 3a7572ff61dbd659121b20791d67469a70e9324d (diff) | |
download | external_llvm-44d798d9763bc32aaf49fe7c10d604845f4b6685.zip external_llvm-44d798d9763bc32aaf49fe7c10d604845f4b6685.tar.gz external_llvm-44d798d9763bc32aaf49fe7c10d604845f4b6685.tar.bz2 |
Add support for a new extension to the .file directive:
.file filenumber "directory" "filename"
This removes one join+split of the directory+filename in MC internals. Because
bitcode files have independent fields for directory and filenames in debug info,
this patch may change the .o files written by existing .bc files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142300 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 1b7e370..9978c82 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -442,23 +442,21 @@ unsigned DwarfDebug::GetOrCreateSourceID(StringRef FileName, if (FileName.empty()) return GetOrCreateSourceID("<stdin>", StringRef()); - // MCStream expects full path name as filename. - if (!DirName.empty() && !sys::path::is_absolute(FileName)) { - SmallString<128> FullPathName = DirName; - sys::path::append(FullPathName, FileName); - // Here FullPathName will be copied into StringMap by GetOrCreateSourceID. - return GetOrCreateSourceID(StringRef(FullPathName), StringRef()); - } - - StringMapEntry<unsigned> &Entry = SourceIdMap.GetOrCreateValue(FileName); - if (Entry.getValue()) - return Entry.getValue(); - - unsigned SrcId = SourceIdMap.size(); - Entry.setValue(SrcId); + unsigned SrcId = SourceIdMap.size()+1; + std::pair<std::string, std::string> SourceName = + std::make_pair(FileName, DirName); + std::pair<std::pair<std::string, std::string>, unsigned> Entry = + make_pair(SourceName, SrcId); + + std::map<std::pair<std::string, std::string>, unsigned>::iterator I; + bool NewlyInserted; + tie(I, NewlyInserted) = SourceIdMap.insert(Entry); + if (!NewlyInserted) + return I->second; // Print out a .file directive to specify files for .loc directives. - Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.getKey()); + Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.first.second, + Entry.first.first); return SrcId; } |