[ClangImporter] Add clang module imports to Swift wrapper module

When macros like _SwiftifyImport are added to a wrapper module for a
clang module, they may need to refer to symbols declared in another
clang module that the wrapped module imports (e.g. because they are used
in the original signature). This adds all the imported clang modules as
implicit imports to the wrapper module.

rdar://151611573
This commit is contained in:
Henrik G. Olsson
2025-05-29 18:46:05 -07:00
parent 33a059f689
commit a43c8474bc
14 changed files with 195 additions and 11 deletions

View File

@@ -321,15 +321,14 @@ void swift::performImportResolution(SourceFile &SF) {
verify(SF);
}
void swift::performImportResolutionForClangMacroBuffer(
SourceFile &SF, ModuleDecl *clangModule
) {
void swift::performImportResolutionForClangMacroBuffer(SourceFile &SF) {
// If we've already performed import resolution, bail.
if (SF.ASTStage == SourceFile::ImportsResolved)
return;
// `getWrapperForModule` has already declared all the implicit clang module
// imports we need
ImportResolver resolver(SF);
resolver.addImplicitImport(clangModule);
// FIXME: This is a hack that we shouldn't need, but be sure that we can
// see the Swift standard library.