diff options
author | Richard Smith <richard@metafoo.co.uk> | 2023-07-21 14:53:36 -0700 |
---|---|---|
committer | Richard Smith <richard@metafoo.co.uk> | 2023-07-21 15:49:47 -0700 |
commit | 7c5e4efb099e0badb4912467b7286938a4ed5011 (patch) | |
tree | 19ac8ab519b9ceb0f1d1ee44f2ee845fa92dbdea /clang/lib | |
parent | 24d293913c211c43af4d1ab0a23ab66d58aea6df (diff) | |
download | llvm-7c5e4efb099e0badb4912467b7286938a4ed5011.zip llvm-7c5e4efb099e0badb4912467b7286938a4ed5011.tar.gz llvm-7c5e4efb099e0badb4912467b7286938a4ed5011.tar.bz2 |
Track the RequestingModule in the HeaderSearch LookupFile cache.
Different requesting modules can have different lookup results, so don't
cache results across modules.
Fixes a regression introduced in reviews.llvm.org/D132779.
Test case based on one provided by Jan Svoboda.
Reviewed By: jansvoboda11
Differential Revision: https://reviews.llvm.org/D156000
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 3200d3d..a5e8b02 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -1008,7 +1008,8 @@ OptionalFileEntryRef HeaderSearch::LookupFile( ConstSearchDirIterator NextIt = std::next(It); if (!SkipCache) { - if (CacheLookup.StartIt == NextIt) { + if (CacheLookup.StartIt == NextIt && + CacheLookup.RequestingModule == RequestingModule) { // HIT: Skip querying potentially lots of directories for this lookup. if (CacheLookup.HitIt) It = CacheLookup.HitIt; @@ -1021,7 +1022,7 @@ OptionalFileEntryRef HeaderSearch::LookupFile( // MISS: This is the first query, or the previous query didn't match // our search start. We will fill in our found location below, so prime // the start point value. - CacheLookup.reset(/*NewStartIt=*/NextIt); + CacheLookup.reset(RequestingModule, /*NewStartIt=*/NextIt); if (It == search_dir_begin() && FirstNonHeaderMapSearchDirIdx > 0) { // Handle cold misses of user includes in the presence of many header @@ -1036,8 +1037,9 @@ OptionalFileEntryRef HeaderSearch::LookupFile( It = search_dir_nth(Iter->second); } } - } else - CacheLookup.reset(/*NewStartIt=*/NextIt); + } else { + CacheLookup.reset(RequestingModule, /*NewStartIt=*/NextIt); + } SmallString<64> MappedName; |