diff options
author | Paul Robinson <paul.robinson@sony.com> | 2018-07-10 14:41:54 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2018-07-10 14:41:54 +0000 |
commit | c17c8bf749e8c9c8e452e4b9cf669e8edf9461de (patch) | |
tree | b5e375b17ad4b398d258a21bb804f6a639ea86af /llvm/lib/MC/MCContext.cpp | |
parent | 3333106a6248635accab6d5b8c2f737ba5d06e6d (diff) | |
download | bcm5719-llvm-c17c8bf749e8c9c8e452e4b9cf669e8edf9461de.tar.gz bcm5719-llvm-c17c8bf749e8c9c8e452e4b9cf669e8edf9461de.zip |
Support -fdebug-prefix-map in llvm-mc. This is useful to omit the
debug compilation dir when compiling assembly files with -g.
Part of PR38050.
Patch by Siddhartha Bagaria!
Differential Revision: https://reviews.llvm.org/D48988
llvm-svn: 336680
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index e4f90f4987a..b601ab24434 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -535,6 +535,26 @@ MCSubtargetInfo &MCContext::getSubtargetCopy(const MCSubtargetInfo &STI) { return *new (MCSubtargetAllocator.Allocate()) MCSubtargetInfo(STI); } +void MCContext::addDebugPrefixMapEntry(const std::string &From, + const std::string &To) { + DebugPrefixMap.insert(std::make_pair(From, To)); +} + +void MCContext::RemapDebugPath(std::string *Path) { + for (const auto &Entry : DebugPrefixMap) + if (StringRef(*Path).startswith(Entry.first)) { + std::string RemappedPath = + (Twine(Entry.second) + Path->substr(Entry.first.size())).str(); + Path->swap(RemappedPath); + } +} + +void MCContext::RemapCompilationDir() { + std::string CompDir = CompilationDir.str(); + RemapDebugPath(&CompDir); + CompilationDir = CompDir; +} + //===----------------------------------------------------------------------===// // Dwarf Management //===----------------------------------------------------------------------===// |