[clang] 00022c5 - [clang][Lex] Header map search case insensitivity

Troy Johnson via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 1 11:37:38 PDT 2022


Author: Troy Johnson
Date: 2022-11-01T11:33:00-07:00
New Revision: 00022c5613a7490148ae1147e25a695fc59c5f92

URL: https://github.com/llvm/llvm-project/commit/00022c5613a7490148ae1147e25a695fc59c5f92
DIFF: https://github.com/llvm/llvm-project/commit/00022c5613a7490148ae1147e25a695fc59c5f92.diff

LOG: [clang][Lex] Header map search case insensitivity

Correct D135801 to be case insensitive.

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

Added: 
    

Modified: 
    clang/lib/Lex/HeaderSearch.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 65316f4e79617..e6af122949709 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -388,7 +388,9 @@ void HeaderSearch::indexInitialHeaderMaps() {
       break;
 
     // Give earlier keys precedence over identical later keys.
-    auto Callback = [&](StringRef Filename) { Index.try_emplace(Filename, i); };
+    auto Callback = [&](StringRef Filename) {
+      Index.try_emplace(Filename.lower(), i);
+    };
     Dir.getHeaderMap()->forEachKey(Callback);
   }
 
@@ -1021,7 +1023,7 @@ Optional<FileEntryRef> HeaderSearch::LookupFile(
         // Handle cold misses of user includes in the presence of many header
         // maps.  We avoid searching perhaps thousands of header maps by
         // jumping directly to the correct one or jumping beyond all of them.
-        auto Iter = SearchDirHeaderMapIndex.find(Filename);
+        auto Iter = SearchDirHeaderMapIndex.find(Filename.lower());
         if (Iter == SearchDirHeaderMapIndex.end())
           // Not in index => Skip to first SearchDir after initial header maps
           It = search_dir_nth(FirstNonHeaderMapSearchDirIdx);


        


More information about the cfe-commits mailing list