mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
cross-module-optimization: Don't serialize functions which reference implementationOnly-imported functions
The check for implementationOnly imports was already done for types, but it was missing for functions. Fixes a crash when implementationOnly-importing a C module. https://bugs.swift.org/browse/SR-15048 rdar://81701218
This commit is contained in:
@@ -2353,14 +2353,15 @@ bool ModuleDecl::isImportedImplementationOnly(const ModuleDecl *module) const {
|
||||
}
|
||||
|
||||
bool ModuleDecl::
|
||||
canBeUsedForCrossModuleOptimization(NominalTypeDecl *nominal) const {
|
||||
ModuleDecl *moduleOfNominal = nominal->getParentModule();
|
||||
canBeUsedForCrossModuleOptimization(DeclContext *ctxt) const {
|
||||
ModuleDecl *moduleOfCtxt = ctxt->getParentModule();
|
||||
|
||||
// If the nominal is defined in the same module, it's fine.
|
||||
if (moduleOfNominal == this)
|
||||
// If the context defined in the same module - or is the same module, it's
|
||||
// fine.
|
||||
if (moduleOfCtxt == this)
|
||||
return true;
|
||||
|
||||
// See if nominal is imported in a "regular" way, i.e. not with
|
||||
// See if context is imported in a "regular" way, i.e. not with
|
||||
// @_implementationOnly or @_spi.
|
||||
ModuleDecl::ImportFilter filter = {
|
||||
ModuleDecl::ImportFilterKind::Exported,
|
||||
@@ -2370,7 +2371,7 @@ canBeUsedForCrossModuleOptimization(NominalTypeDecl *nominal) const {
|
||||
|
||||
auto &imports = getASTContext().getImportCache();
|
||||
for (auto &desc : results) {
|
||||
if (imports.isImportedBy(moduleOfNominal, desc.importedModule))
|
||||
if (imports.isImportedBy(moduleOfCtxt, desc.importedModule))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user