diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Basic/CodeGenOptions.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Driver/Options.td | 3 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 9 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 3 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | clang/test/CodeGen/debug-prefix-map.c | 7 | ||||
-rw-r--r-- | clang/tools/driver/cc1as_main.cpp | 5 |
7 files changed, 15 insertions, 17 deletions
diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 6192d3f..662271f 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -206,7 +206,7 @@ public: /// if non-empty. std::string RecordCommandLine; - std::map<std::string, std::string> DebugPrefixMap; + llvm::SmallVector<std::pair<std::string, std::string>, 0> DebugPrefixMap; std::map<std::string, std::string> CoveragePrefixMap; /// The ABI to use for passing floating point arguments. diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index eb48c14..c8f505a 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3218,7 +3218,8 @@ def fdebug_default_version: Joined<["-"], "fdebug-default-version=">, Group<f_Gr def fdebug_prefix_map_EQ : Joined<["-"], "fdebug-prefix-map=">, Group<f_Group>, Flags<[CC1Option,CC1AsOption]>, - HelpText<"remap file source paths in debug info">; + MetaVarName<"<old>=<new>">, + HelpText<"For paths in debug info, remap directory <old> to <new>. If multiple options match a path, the last option wins">; def fcoverage_prefix_map_EQ : Joined<["-"], "fcoverage-prefix-map=">, Group<f_Group>, Flags<[CC1Option]>, diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 5100d6c..2cf7b02 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -73,8 +73,6 @@ CGDebugInfo::CGDebugInfo(CodeGenModule &CGM) : CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()), DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs), DBuilder(CGM.getModule()) { - for (const auto &KV : CGM.getCodeGenOpts().DebugPrefixMap) - DebugPrefixMap[KV.first] = KV.second; CreateCompileUnit(); } @@ -470,12 +468,9 @@ llvm::DIFile *CGDebugInfo::createFile( } std::string CGDebugInfo::remapDIPath(StringRef Path) const { - if (DebugPrefixMap.empty()) - return Path.str(); - SmallString<256> P = Path; - for (const auto &Entry : DebugPrefixMap) - if (llvm::sys::path::replace_path_prefix(P, Entry.first, Entry.second)) + for (auto &[From, To] : llvm::reverse(CGM.getCodeGenOpts().DebugPrefixMap)) + if (llvm::sys::path::replace_path_prefix(P, From, To)) break; return P.str().str(); } diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 5a3839d..5c42d36 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -86,9 +86,6 @@ class CGDebugInfo { /// Cache of previously constructed Types. llvm::DenseMap<const void *, llvm::TrackingMDRef> TypeCache; - std::map<llvm::StringRef, llvm::StringRef, std::greater<llvm::StringRef>> - DebugPrefixMap; - /// Cache that maps VLA types to size expressions for that type, /// represented by instantiated Metadata nodes. llvm::SmallDenseMap<QualType, llvm::Metadata *> SizeExprCache; diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 71204de..a148136 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1696,8 +1696,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) { auto Split = StringRef(Arg).split('='); - Opts.DebugPrefixMap.insert( - {std::string(Split.first), std::string(Split.second)}); + Opts.DebugPrefixMap.emplace_back(Split.first, Split.second); } for (const auto &Arg : Args.getAllArgValues(OPT_fcoverage_prefix_map_EQ)) { diff --git a/clang/test/CodeGen/debug-prefix-map.c b/clang/test/CodeGen/debug-prefix-map.c index f604f16..e242180 100644 --- a/clang/test/CodeGen/debug-prefix-map.c +++ b/clang/test/CodeGen/debug-prefix-map.c @@ -9,6 +9,10 @@ // RUN: %clang -g -fdebug-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL // RUN: %clang -g -ffile-prefix-map=%p=./UNLIKELY_PATH/empty -S -c %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-REL +// RUN: rm -rf %t && mkdir -p %t/a/b && cp %s %t/a/b/c.c +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -I%S -fdebug-prefix-map=%t/a/b=y -fdebug-prefix-map=%t/a=x %t/a/b/c.c -o - | FileCheck %s --check-prefix=CHECK-X +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -I%S -fdebug-prefix-map=%t/a=x -fdebug-prefix-map=%t/a/b=y %t/a/b/c.c -o - | FileCheck %s --check-prefix=CHECK-Y + #include "Inputs/stdio.h" int main(int argc, char **argv) { @@ -47,3 +51,6 @@ void test_rewrite_includes(void) { // CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}", // CHECK-REL: !DIFile(filename: "./UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}Inputs/stdio.h", // CHECK-REL-SAME: directory: "" + +// CHECK-X: !DIFile(filename: "x{{/|\\\\}}b{{/|\\\\}}c.c", directory: "") +// CHECK-Y: !DIFile(filename: "y{{/|\\\\}}c.c", directory: "") diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index ee54a0f7..ecfb1be 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -97,7 +97,7 @@ struct AssemblerInvocation { std::string DwarfDebugFlags; std::string DwarfDebugProducer; std::string DebugCompilationDir; - std::map<const std::string, const std::string> DebugPrefixMap; + llvm::SmallVector<std::pair<std::string, std::string>, 0> DebugPrefixMap; llvm::DebugCompressionType CompressDebugSections = llvm::DebugCompressionType::None; std::string MainFileName; @@ -275,8 +275,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts, for (const auto &Arg : Args.getAllArgValues(OPT_fdebug_prefix_map_EQ)) { auto Split = StringRef(Arg).split('='); - Opts.DebugPrefixMap.insert( - {std::string(Split.first), std::string(Split.second)}); + Opts.DebugPrefixMap.emplace_back(Split.first, Split.second); } // Frontend Options |