diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -1720,5 +1720,5 @@ if (IsSystem) *IsSystem = BestPrefixLength ? BestSearchDir >= SystemDirIdx : false; - return File.drop_front(BestPrefixLength); + return path::convert_to_slash(File.drop_front(BestPrefixLength)); } diff --git a/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/unittests/Lex/HeaderSearchTest.cpp @@ -91,5 +91,14 @@ "z"); } +#ifdef _WIN32 +TEST_F(HeaderSearchTest, BackSlash) { + addSearchDir("C:\\x\\y\\"); + EXPECT_EQ(Search.suggestPathToFileForDiagnostics("C:\\x\\y\\z\\t", + /*WorkingDir=*/""), + "z/t"); +} +#endif + } // namespace } // namespace clang