mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SILOptimizer] Don't apply CMO to key paths that reference inaccessible properties
rdar://145095088
This commit is contained in:
@@ -651,6 +651,21 @@ bool CrossModuleOptimization::canSerializeFieldsByInstructionKind(
|
||||
canUse = methodScope.isPublicOrPackage();
|
||||
}
|
||||
});
|
||||
auto pattern = KPI->getPattern();
|
||||
for (auto &component : pattern->getComponents()) {
|
||||
if (!canUse) {
|
||||
break;
|
||||
}
|
||||
switch (component.getKind()) {
|
||||
case KeyPathPatternComponent::Kind::StoredProperty: {
|
||||
auto property = component.getStoredPropertyDecl();
|
||||
canUse = isPackageOrPublic(property->getEffectiveAccess());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return canUse;
|
||||
}
|
||||
if (auto *MI = dyn_cast<MethodInst>(inst)) {
|
||||
|
||||
Reference in New Issue
Block a user