From 00022c5613a7490148ae1147e25a695fc59c5f92 Mon Sep 17 00:00:00 2001 From: Troy Johnson Date: Tue, 1 Nov 2022 11:06:30 -0700 Subject: [PATCH] [clang][Lex] Header map search case insensitivity Correct D135801 to be case insensitive. Differential Revision: https://reviews.llvm.org/D137179 --- clang/lib/Lex/HeaderSearch.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 65316f4..e6af122 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 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); -- 2.7.4