summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2019-06-06 18:49:16 +0000
committerKadir Cetinkaya <kadircet@google.com>2019-06-06 18:49:16 +0000
commit51f85b40bc6ccfce3d6f3c8d984ce6af2336116f (patch)
tree6017b34cbcd38c94b41634ddb54e4267de123106
parent06de52674da73f30751f3ff19fdf457f87077c65 (diff)
downloadbcm5719-llvm-51f85b40bc6ccfce3d6f3c8d984ce6af2336116f.tar.gz
bcm5719-llvm-51f85b40bc6ccfce3d6f3c8d984ce6af2336116f.zip
[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
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp5
-rw-r--r--clang/unittests/Lex/HeaderSearchTest.cpp7
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 16a53bf634a..3ad0e1e5e83 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 5bcdd9efd17..499acec9bfd 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) {
OpenPOWER on IntegriCloud