AST: Cache underlying clang module during import resolution.

As recommended in feedback on https://github.com/apple/swift/pull/71302, cache
the underlying clang module after loading it in `ImportResolver`, rather than
filtering it out of the overall set of resolved imports. This is more efficient
and results in less duplicated code that must identify the underlying clang
module.
This commit is contained in:
Allan Shortlidge
2024-02-01 16:53:51 -08:00
parent 8fd77e3b51
commit e056c73fb1
3 changed files with 20 additions and 16 deletions

View File

@@ -406,6 +406,13 @@ public:
/// resolution.
void setImports(ArrayRef<AttributedImport<ImportedModule>> imports);
/// Set the imported underlying clang module for this source file. This gets
/// called by import resolution.
void setImportedUnderlyingModule(ModuleDecl *module) {
assert(!ImportedUnderlyingModule && "underlying module already set");
ImportedUnderlyingModule = module;
}
/// Whether the given import has used @preconcurrency.
bool hasImportUsedPreconcurrency(
AttributedImport<ImportedModule> import) const;