From 51f85b40bc6ccfce3d6f3c8d984ce6af2336116f Mon Sep 17 00:00:00 2001 From: Kadir Cetinkaya Date: Thu, 6 Jun 2019 18:49:16 +0000 Subject: [PATCH] [clang][HeaderSearch] Consider all path separators equal Reviewers: ilya-biryukov, sammccall Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62965 llvm-svn: 362731 --- clang/lib/Lex/HeaderSearch.cpp | 5 +++++ clang/unittests/Lex/HeaderSearchTest.cpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 16a53bf..3ad0e1e 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/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/clang/unittests/Lex/HeaderSearchTest.cpp b/clang/unittests/Lex/HeaderSearchTest.cpp index 5bcdd9e..499acec 100644 --- a/clang/unittests/Lex/HeaderSearchTest.cpp +++ b/clang/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) { -- 2.7.4