[C++20][Modules][6/8] Record direct module imports.

This is a small cache to avoid having to check both Exports and
Imports.

Differential Revision: https://reviews.llvm.org/D118589
This commit is contained in:
Iain Sandoe 2022-01-30 14:26:57 +00:00
parent 2bbe6506d4
commit 853ca54723
2 changed files with 12 additions and 0 deletions

View File

@ -2219,6 +2219,9 @@ private:
/// The global module fragment of the current translation unit.
clang::Module *GlobalModuleFragment = nullptr;
/// The modules we imported directly.
llvm::SmallPtrSet<clang::Module *, 8> DirectModuleImports;
/// Namespace definitions that we will export when they finish.
llvm::SmallPtrSet<const NamespaceDecl*, 8> DeferredExportedNamespaces;
@ -2246,6 +2249,10 @@ public:
return Entity->getOwningModule();
}
bool isModuleDirectlyImported(const Module *M) {
return DirectModuleImports.contains(M);
}
/// Make a merged definition of an existing hidden definition \p ND
/// visible at the specified location.
void makeMergedDefinitionVisible(NamedDecl *ND);

View File

@ -514,6 +514,11 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
assert(ThisModule && "was expecting a module if building one");
}
// In some cases we need to know if an entity was present in a directly-
// imported module (as opposed to a transitive import). This avoids
// searching both Imports and Exports.
DirectModuleImports.insert(Mod);
return Import;
}