@@ -223,6 +223,32 @@ cl::opt<bool> emitDwarfDebugInfo(
223223 " gdwarf" , cl::ZeroOrMore,
224224 cl::desc (" Emit DWARF debuginfo (instead of CodeView) for MSVC targets" ));
225225
226+ // Prefix map for filenames in DWARF debuginfo
227+ std::map<std::string, std::string> debugPrefixMap;
228+
229+ struct DwarfPrefixParser : public cl ::parser<std::string> {
230+ explicit DwarfPrefixParser (cl::Option &O) : cl::parser<std::string>(O) {}
231+
232+ bool parse (cl::Option &O, llvm::StringRef /* ArgName*/ , llvm::StringRef Arg,
233+ std::string & /* Val*/ ) {
234+ auto [from, to] = Arg.split (' =' );
235+ if (from.empty () || to.empty ()) {
236+ return O.error (" invalid debug prefix map: " + Arg);
237+ }
238+ auto fromStr = std::string (from);
239+ if (debugPrefixMap.find (fromStr) != debugPrefixMap.end ()) {
240+ return O.error (" debug prefix map already contains: " + fromStr);
241+ }
242+ debugPrefixMap[fromStr] = std::string (to);
243+ return false ;
244+ }
245+ };
246+
247+ static cl::opt<std::string, false , DwarfPrefixParser> fdebugPrefixMap (
248+ " fdebug-prefix-map" , cl::ZeroOrMore,
249+ cl::desc (" Prefix map for filenames in DWARF debuginfo" ),
250+ cl::value_desc(" <old>=<new>" ));
251+
226252cl::opt<bool > noAsm (" noasm" , cl::desc(" Disallow use of inline assembler" ),
227253 cl::ZeroOrMore);
228254
0 commit comments