kadircet created this revision. kadircet added reviewers: ilya-biryukov, sammccall. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D62965 Files: clang/lib/Lex/HeaderSearch.cpp clang/unittests/Lex/HeaderSearchTest.cpp Index: clang/unittests/Lex/HeaderSearchTest.cpp =================================================================== --- clang/unittests/Lex/HeaderSearchTest.cpp +++ clang/unittests/Lex/HeaderSearchTest.cpp @@ -98,6 +98,13 @@ /*WorkingDir=*/""), "z/t"); } + +TEST_F(HeaderSearchTest, BackSlashWithDotDot) { + addSearchDir("..\\y"); + EXPECT_EQ(Search.suggestPathToFileForDiagnostics("C:\\x\\y\\z\\t", + /*WorkingDir=*/"C:/x/y/"), + "z/t"); +} #endif TEST_F(HeaderSearchTest, DotDotsWithAbsPath) { Index: clang/lib/Lex/HeaderSearch.cpp =================================================================== --- clang/lib/Lex/HeaderSearch.cpp +++ clang/lib/Lex/HeaderSearch.cpp @@ -1715,6 +1715,11 @@ break; } + // Ignore path separators. + if (NI->size() == 1 && DI->size() == 1 && + path::is_separator(NI->front()) && path::is_separator(DI->front())) + continue; + if (*NI != *DI) break; }
Index: clang/unittests/Lex/HeaderSearchTest.cpp =================================================================== --- clang/unittests/Lex/HeaderSearchTest.cpp +++ clang/unittests/Lex/HeaderSearchTest.cpp @@ -98,6 +98,13 @@ /*WorkingDir=*/""), "z/t"); } + +TEST_F(HeaderSearchTest, BackSlashWithDotDot) { + addSearchDir("..\\y"); + EXPECT_EQ(Search.suggestPathToFileForDiagnostics("C:\\x\\y\\z\\t", + /*WorkingDir=*/"C:/x/y/"), + "z/t"); +} #endif TEST_F(HeaderSearchTest, DotDotsWithAbsPath) { Index: clang/lib/Lex/HeaderSearch.cpp =================================================================== --- clang/lib/Lex/HeaderSearch.cpp +++ clang/lib/Lex/HeaderSearch.cpp @@ -1715,6 +1715,11 @@ break; } + // Ignore path separators. + if (NI->size() == 1 && DI->size() == 1 && + path::is_separator(NI->front()) && path::is_separator(DI->front())) + continue; + if (*NI != *DI) break; }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits