diff options
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 6 | ||||
| -rw-r--r-- | clang/test/CodeGen/debug-prefix-map.c | 12 |
3 files changed, 12 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 282a8e44d38..db5893a7b51 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -476,12 +476,10 @@ CGDebugInfo::createFile(StringRef FileName, } std::string CGDebugInfo::remapDIPath(StringRef Path) const { - SmallString<256> p = Path; for (const auto &Entry : DebugPrefixMap) - if (llvm::sys::path::replace_path_prefix( - p, Entry.first, Entry.second, llvm::sys::path::Style::native, true)) - break; - return p.str(); + if (Path.startswith(Entry.first)) + return (Twine(Entry.second) + Path.substr(Entry.first.size())).str(); + return Path.str(); } unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) { diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index 3b53d07cc4a..cf8bb2fbab9 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1456,10 +1456,10 @@ static void remapMacroPath( const std::map<std::string, std::string, std::greater<std::string>> &MacroPrefixMap) { for (const auto &Entry : MacroPrefixMap) - if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second, - llvm::sys::path::Style::native, - true)) + if (Path.startswith(Entry.first)) { + Path = (Twine(Entry.second) + Path.substr(Entry.first.size())).str(); break; + } } /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded diff --git a/clang/test/CodeGen/debug-prefix-map.c b/clang/test/CodeGen/debug-prefix-map.c index abebc9a1510..5366e19447a 100644 --- a/clang/test/CodeGen/debug-prefix-map.c +++ b/clang/test/CodeGen/debug-prefix-map.c @@ -19,21 +19,21 @@ void test_rewrite_includes() { } // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|\\\\}}<stdin>" -// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}", +// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}", // On POSIX systems "Dir" should actually be empty, but on Windows we // can't recognize "/UNLIKELY_PATH" as being an absolute path. // CHECK-NO-MAIN-FILE-NAME-SAME: directory: "{{()|(.*:.*)}}") -// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/UNLIKELY_PATH/empty{{[/\\]}}Inputs/stdio.h", +// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|\\\\}}Inputs/stdio.h", // CHECK-NO-MAIN-FILE-NAME-SAME: directory: "{{()|(.*:.*)}}") // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename: -// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{[/\\]}}{{.*}}" -// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{[/\\]}}{{.*}}Inputs/stdio.h", +// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|\\\\}}{{.*}}" +// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|\\\\}}{{.*}}Inputs/stdio.h", // CHECK-EVIL-SAME: directory: "{{()|(.*:.*)}}") // CHECK-EVIL-NOT: !DIFile(filename: -// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}" -// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}Inputs/stdio.h", +// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}" +// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}Inputs/stdio.h", // CHECK-SAME: directory: "{{()|(.*:.*)}}") // CHECK-NOT: !DIFile(filename: |

