Skip to content

Commit 08c0571

Browse files
committed
SIL: don't add effects attributes for storage decls.
Only for accessor functions. This is important because the clang importer sets "readonly" attributes for a getter also on the storage decl, which would propagate to the setter. This PR restores the old behavior which was changed by #40957. Unfortunately I don't have a test case. rdar://88876417
1 parent adabdcb commit 08c0571

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/SIL/IR/SILFunctionBuilder.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,19 @@ void SILFunctionBuilder::addFunctionAttributes(
101101
}
102102

103103
llvm::SmallVector<const EffectsAttr *, 8> customEffects;
104-
for (auto *attr : Attrs.getAttributes<EffectsAttr>()) {
105-
auto *effectsAttr = cast<EffectsAttr>(attr);
106-
if (effectsAttr->getKind() == EffectsKind::Custom) {
107-
customEffects.push_back(effectsAttr);
108-
} else {
109-
if (F->getEffectsKind() != EffectsKind::Unspecified &&
110-
F->getEffectsKind() != effectsAttr->getKind()) {
111-
mod.getASTContext().Diags.diagnose(effectsAttr->getLocation(),
112-
diag::warning_in_effects_attribute, "mismatching function effects");
104+
if (constant) {
105+
for (auto *attr : Attrs.getAttributes<EffectsAttr>()) {
106+
auto *effectsAttr = cast<EffectsAttr>(attr);
107+
if (effectsAttr->getKind() == EffectsKind::Custom) {
108+
customEffects.push_back(effectsAttr);
113109
} else {
114-
F->setEffectsKind(effectsAttr->getKind());
110+
if (F->getEffectsKind() != EffectsKind::Unspecified &&
111+
F->getEffectsKind() != effectsAttr->getKind()) {
112+
mod.getASTContext().Diags.diagnose(effectsAttr->getLocation(),
113+
diag::warning_in_effects_attribute, "mismatching function effects");
114+
} else {
115+
F->setEffectsKind(effectsAttr->getKind());
116+
}
115117
}
116118
}
117119
}

0 commit comments

Comments
 (0)