diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1895,9 +1895,9 @@ LangOpts.remapPathPrefix(Path); if (LangOpts.UseTargetPathSeparator) { if (TI.getTriple().isOSWindows()) - llvm::sys::path::make_preferred( - Path, llvm::sys::path::Style::windows_backslash); + llvm::sys::path::remove_dots(Path, false, + llvm::sys::path::Style::windows_backslash); else - llvm::sys::path::make_preferred(Path, llvm::sys::path::Style::posix); + llvm::sys::path::remove_dots(Path, false, llvm::sys::path::Style::posix); } } diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -765,6 +765,9 @@ return false; SmallString<256> buffer = root; + // "root" could be "/", which may need to be translated into "\". + make_preferred(buffer, style); + if (!components.empty()) { buffer += components[0]; for (StringRef C : makeArrayRef(components).drop_front()) {