Skip to content

Commit 4ec6f94

Browse files
committed
Fix printing @Lifetime(&arg) for accessors in swiftinterface files
1 parent 7a28b5f commit 4ec6f94

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/AST/FeatureSet.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,26 @@ static bool usesFeatureLifetimeDependence(Decl *decl) {
272272
}
273273

274274
static bool usesFeatureInoutLifetimeDependence(Decl *decl) {
275-
for (auto attr : decl->getAttrs().getAttributes<LifetimeAttr>()) {
276-
for (auto source : attr->getLifetimeEntry()->getSources()) {
277-
if (source.getParsedLifetimeDependenceKind() ==
278-
ParsedLifetimeDependenceKind::Inout) {
279-
return true;
275+
auto hasInoutLifetimeDependence = [](Decl *decl) {
276+
for (auto attr : decl->getAttrs().getAttributes<LifetimeAttr>()) {
277+
for (auto source : attr->getLifetimeEntry()->getSources()) {
278+
if (source.getParsedLifetimeDependenceKind() ==
279+
ParsedLifetimeDependenceKind::Inout) {
280+
return true;
281+
}
280282
}
281283
}
284+
return false;
285+
};
286+
287+
switch (decl->getKind()) {
288+
case DeclKind::Var: {
289+
auto *var = cast<VarDecl>(decl);
290+
return llvm::any_of(var->getAllAccessors(), hasInoutLifetimeDependence);
291+
}
292+
default:
293+
return hasInoutLifetimeDependence(decl);
282294
}
283-
return false;
284295
}
285296

286297
UNINTERESTING_FEATURE(DynamicActorIsolation)

0 commit comments

Comments
 (0)