From c17c8bf749e8c9c8e452e4b9cf669e8edf9461de Mon Sep 17 00:00:00 2001 From: Paul Robinson Date: Tue, 10 Jul 2018 14:41:54 +0000 Subject: 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 --- llvm/lib/MC/MCContext.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'llvm/lib/MC/MCContext.cpp') 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 //===----------------------------------------------------------------------===// -- cgit v1.2.3