From: Kadir Cetinkaya Date: Thu, 6 Jun 2019 18:49:16 +0000 (+0000) Subject: [clang][HeaderSearch] Consider all path separators equal X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5175654bee59d5b608d7d244aaeba455b1500be8;p=clang [clang][HeaderSearch] Consider all path separators equal Reviewers: ilya-biryukov, sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62965 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362731 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index 16a53bf634..3ad0e1e5e8 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -1715,6 +1715,11 @@ std::string HeaderSearch::suggestPathToFileForDiagnostics( break; } + // Consider all path separators equal. + if (NI->size() == 1 && DI->size() == 1 && + path::is_separator(NI->front()) && path::is_separator(DI->front())) + continue; + if (*NI != *DI) break; } diff --git a/unittests/Lex/HeaderSearchTest.cpp b/unittests/Lex/HeaderSearchTest.cpp index 5bcdd9efd1..499acec9bf 100644 --- a/unittests/Lex/HeaderSearchTest.cpp +++ b/unittests/Lex/HeaderSearchTest.cpp @@ -98,6 +98,13 @@ TEST_F(HeaderSearchTest, BackSlash) { /*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) {