r362731 - [clang][HeaderSearch] Consider all path separators equal

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 6 11:49:16 PDT 2019


Author: kadircet
Date: Thu Jun  6 11:49:16 2019
New Revision: 362731

URL: http://llvm.org/viewvc/llvm-project?rev=362731&view=rev
Log:
[clang][HeaderSearch] Consider all path separators equal

Reviewers: ilya-biryukov, sammccall

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62965

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

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=362731&r1=362730&r2=362731&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Jun  6 11:49:16 2019
@@ -1715,6 +1715,11 @@ std::string HeaderSearch::suggestPathToF
         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;
     }

Modified: cfe/trunk/unittests/Lex/HeaderSearchTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/HeaderSearchTest.cpp?rev=362731&r1=362730&r2=362731&view=diff
==============================================================================
--- cfe/trunk/unittests/Lex/HeaderSearchTest.cpp (original)
+++ cfe/trunk/unittests/Lex/HeaderSearchTest.cpp Thu Jun  6 11:49:16 2019
@@ -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) {




More information about the cfe-commits mailing list