aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Lex/HeaderSearch.cpp
diff options
context:
space:
mode:
authorIvan Murashko <ivan.murashko@gmail.com>2023-05-28 11:47:29 +0100
committerIvan Murashko <ivan.murashko@gmail.com>2023-05-28 11:49:51 +0100
commitf8536fb11e3d71d009c9002b5aa2ef32983ac7dc (patch)
tree4a8c084f8825837edcd318afbd623ae66a49134c /clang/lib/Lex/HeaderSearch.cpp
parent684facbb43ea0eccc6a579d2373781b422522d2d (diff)
downloadllvm-f8536fb11e3d71d009c9002b5aa2ef32983ac7dc.zip
llvm-f8536fb11e3d71d009c9002b5aa2ef32983ac7dc.tar.gz
llvm-f8536fb11e3d71d009c9002b5aa2ef32983ac7dc.tar.bz2
[clang][HeaderSearch] Fix implicit module when using header maps
Previously, if a header was found via in a header map, and not just remapped. we wouldn't also find the module it maps to when using implicit modules (for module maps that were explicitly loaded). This diff just updates these code paths to also locate the owning module via `findUsableModuleForHeader`. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D103930
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index a650bbe..d09d3ae 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -491,7 +491,8 @@ OptionalFileEntryRef DirectoryLookup::LookupFile(
IsInHeaderMap = true;
- auto FixupSearchPath = [&]() {
+ auto FixupSearchPathAndFindUsableModule =
+ [&](auto File) -> OptionalFileEntryRef {
if (SearchPath) {
StringRef SearchPathRef(getName());
SearchPath->clear();
@@ -501,6 +502,12 @@ OptionalFileEntryRef DirectoryLookup::LookupFile(
RelativePath->clear();
RelativePath->append(Filename.begin(), Filename.end());
}
+ if (!HS.findUsableModuleForHeader(
+ &File.getFileEntry(), File.getFileEntry().getDir(),
+ RequestingModule, SuggestedModule, isSystemHeaderDirectory())) {
+ return std::nullopt;
+ }
+ return File;
};
// Check if the headermap maps the filename to a framework include
@@ -513,8 +520,7 @@ OptionalFileEntryRef DirectoryLookup::LookupFile(
}
if (auto Res = HS.getFileMgr().getOptionalFileRef(Dest, OpenFile)) {
- FixupSearchPath();
- return *Res;
+ return FixupSearchPathAndFindUsableModule(*Res);
}
// Header maps need to be marked as used whenever the filename matches.