ClangImporter: import SPIs from bridging headers by default

rdar://82822440
This commit is contained in:
Xi Ge
2021-09-07 14:54:34 -07:00
parent eb8e52b8d6
commit 4e4bae64cb
2 changed files with 20 additions and 0 deletions

View File

@@ -492,6 +492,8 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
auto *clangImporter =
static_cast<ClangImporter *>(ctx.getClangModuleLoader());
SmallVector<Identifier, 4> clangSpiGroups;
clangSpiGroups.push_back(ctx.getIdentifier(CLANG_MODULE_DEFUALT_SPI_GROUP_NAME));
// Implicitly import the bridging header module if needed.
auto bridgingHeaderPath = importInfo.BridgingHeaderPath;
if (!bridgingHeaderPath.empty() &&
@@ -499,6 +501,8 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
auto *headerModule = clangImporter->getImportedHeaderModule();
assert(headerModule && "Didn't load bridging header?");
imports.emplace_back(ImportedModule(headerModule), ImportFlags::Exported);
imports.back().options |= ImportFlags::SPIAccessControl;
imports.back().spiGroups = ctx.AllocateCopy(clangSpiGroups);
}
// Implicitly import the underlying Clang half of this module if needed.
@@ -509,6 +513,8 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
unloadedImports.emplace_back(UnloadedImportedModule(importPath.copyTo(ctx),
/*isScoped=*/false),
ImportFlags::Exported);
imports.back().options |= ImportFlags::SPIAccessControl;
imports.back().spiGroups = ctx.AllocateCopy(clangSpiGroups);
}
return { ctx.AllocateCopy(imports), ctx.AllocateCopy(unloadedImports) };