From f35230ae0a69bbdd74a4faa3ae0b69a46796dc12 Mon Sep 17 00:00:00 2001 From: Jan Svoboda Date: Thu, 22 Sep 2022 12:17:52 -0700 Subject: [clang][modules][deps] Report modulemaps describing excluded headers Module map files describing excluded headers do affect compilation. Track them in the compiler, serialize them into the PCM file and report them in the scanner. Depends on D134222. Reviewed By: Bigcheese Differential Revision: https://reviews.llvm.org/D134224 --- clang/lib/Lex/ModuleMap.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'clang/lib/Lex/ModuleMap.cpp') diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp index 87a90bc..174d639 100644 --- a/clang/lib/Lex/ModuleMap.cpp +++ b/clang/lib/Lex/ModuleMap.cpp @@ -567,9 +567,11 @@ static bool isBetterKnownHeader(const ModuleMap::KnownHeader &New, } ModuleMap::KnownHeader ModuleMap::findModuleForHeader(const FileEntry *File, - bool AllowTextual) { + bool AllowTextual, + bool AllowExcluded) { auto MakeResult = [&](ModuleMap::KnownHeader R) -> ModuleMap::KnownHeader { - if (!AllowTextual && R.getRole() & ModuleMap::TextualHeader) + if ((!AllowTextual && R.getRole() & ModuleMap::TextualHeader) || + (!AllowExcluded && R.getRole() & ModuleMap::ExcludedHeader)) return {}; return R; }; @@ -700,6 +702,9 @@ ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header, E = Known->second.end(); I != E; ++I) { + if (I->getRole() == ModuleMap::ExcludedHeader) + continue; + if (I->isAvailable() && (!RequestingModule || I->getModule()->isSubModuleOf(RequestingModule))) { @@ -1261,11 +1266,13 @@ void ModuleMap::addHeader(Module *Mod, Module::Header Header, } void ModuleMap::excludeHeader(Module *Mod, Module::Header Header) { + KnownHeader KH(Mod, ModuleHeaderRole::ExcludedHeader); + // Add this as a known header so we won't implicitly add it to any // umbrella directory module. // FIXME: Should we only exclude it from umbrella modules within the // specified module? - (void) Headers[Header.Entry]; + Headers[Header.Entry].push_back(KH); Mod->Headers[Module::HK_Excluded].push_back(std::move(Header)); } -- cgit v1.1