Skip to content

Commit 7496505

Browse files
authored
Merge pull request #8560 from apple/jan_svoboda/affecting-mm-only-with-search
[clang][modules] Only compute affecting module maps with implicit search
2 parents 39d3e65 + a14a33e commit 7496505

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ static TypeCode getTypeCodeForTypeClass(Type::TypeClass id) {
161161

162162
namespace {
163163

164-
std::set<const FileEntry *> GetAffectingModuleMaps(const Preprocessor &PP,
165-
Module *RootModule) {
164+
std::optional<std::set<const FileEntry *>>
165+
GetAffectingModuleMaps(const Preprocessor &PP, Module *RootModule) {
166+
// Without implicit module map search, there's no good reason to know about
167+
// any module maps that are not affecting.
168+
if (!PP.getHeaderSearchInfo().getHeaderSearchOpts().ImplicitModuleMaps)
169+
return std::nullopt;
170+
166171
SmallVector<const Module *> ModulesToProcess{RootModule};
167172

168173
const HeaderSearch &HS = PP.getHeaderSearchInfo();
@@ -4682,8 +4687,16 @@ void ASTWriter::computeNonAffectingInputFiles() {
46824687
if (!Cache->OrigEntry)
46834688
continue;
46844689

4685-
if (!isModuleMap(File.getFileCharacteristic()) ||
4686-
llvm::is_contained(AffectingModuleMaps, *Cache->OrigEntry))
4690+
// Don't prune anything other than module maps.
4691+
if (!isModuleMap(File.getFileCharacteristic()))
4692+
continue;
4693+
4694+
// Don't prune module maps if all are guaranteed to be affecting.
4695+
if (!AffectingModuleMaps)
4696+
continue;
4697+
4698+
// Don't prune module maps that are affecting.
4699+
if (llvm::is_contained(*AffectingModuleMaps, *Cache->OrigEntry))
46874700
continue;
46884701

46894702
IsSLocAffecting[I] = false;

0 commit comments

Comments
 (0)