diff options
| author | Fangrui Song <maskray@google.com> | 2019-11-26 16:09:22 -0800 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2019-11-26 16:15:39 -0800 |
| commit | 3bb24bf25767ef5bbcef958b484e7a06d8689204 (patch) | |
| tree | cd911a5c9b0ba7a12a5c2024312baa034c697805 /clang/lib | |
| parent | df773ebb5f8ff54cda385f4491ff877464228c18 (diff) | |
| download | bcm5719-llvm-3bb24bf25767ef5bbcef958b484e7a06d8689204.tar.gz bcm5719-llvm-3bb24bf25767ef5bbcef958b484e7a06d8689204.zip | |
Fix tests on Windows after D49466
It is tricky to use replace_path_prefix correctly on Windows which uses
backslashes as native path separators. Switch back to the old approach
(startswith is not ideal) to appease build bots for now.
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 6 |
2 files changed, 6 insertions, 8 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 |

