[PATCH] D62965: [clang][HeaderSearch] Consider all path separators equal

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 6 09:33:47 PDT 2019


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;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62965.203388.patch
Type: text/x-patch
Size: 1084 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190606/5330d289/attachment.bin>


More information about the cfe-commits mailing list