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

Kadir Cetinkaya via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 6 11:46:45 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL362731: [clang][HeaderSearch] Consider all path separators equal (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62965?vs=203399&id=203409#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62965/new/

https://reviews.llvm.org/D62965

Files:
  cfe/trunk/lib/Lex/HeaderSearch.cpp
  cfe/trunk/unittests/Lex/HeaderSearchTest.cpp


Index: cfe/trunk/lib/Lex/HeaderSearch.cpp
===================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp
@@ -1715,6 +1715,11 @@
         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;
     }
Index: cfe/trunk/unittests/Lex/HeaderSearchTest.cpp
===================================================================
--- cfe/trunk/unittests/Lex/HeaderSearchTest.cpp
+++ cfe/trunk/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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62965.203409.patch
Type: text/x-patch
Size: 1120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190606/0516c351/attachment.bin>


More information about the llvm-commits mailing list