From daad48d6b236d74c6b29daebba46289b98104241 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 25 Apr 2023 15:12:17 -0700 Subject: -fdebug-prefix-map=: make the last win when multiple prefixes match For `clang -c -g -fdebug-prefix-map=a/b=y -fdebug-prefix-map=a=x a/b/c.c`, we apply the longest prefix substitution, but GCC has always been picking the last applicable option (`a=x`, see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109591). I feel that GCC's behavior is reasonable given the convention that the last value wins for the same option. Before D49466, Clang appeared to apply the shortest prefix substitution, which likely made the least sense. Reviewed By: #debug-info, scott.linder Differential Revision: https://reviews.llvm.org/D148975 --- clang/lib/Frontend/CompilerInvocation.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'clang/lib/Frontend/CompilerInvocation.cpp') 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)) { -- cgit v1.1