Skip to content

Commit 5fac8a4

Browse files
committed
Fix printing @Lifetime(&arg) for accessors in swiftinterface files
1 parent ef1e945 commit 5fac8a4

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
@@ -271,15 +271,26 @@ static bool usesFeatureLifetimeDependence(Decl *decl) {
271271
}
272272

273273
static bool usesFeatureInoutLifetimeDependence(Decl *decl) {
274-
for (auto attr : decl->getAttrs().getAttributes<LifetimeAttr>()) {
275-
for (auto source : attr->getLifetimeEntry()->getSources()) {
276-
if (source.getParsedLifetimeDependenceKind() ==
277-
ParsedLifetimeDependenceKind::Inout) {
278-
return true;
274+
auto hasInoutLifetimeDependence = [](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;
280+
}
279281
}
280282
}
283+
return false;
284+
};
285+
286+
switch (decl->getKind()) {
287+
case DeclKind::Var: {
288+
auto *var = cast<VarDecl>(decl);
289+
return llvm::any_of(var->getAllAccessors(), hasInoutLifetimeDependence);
290+
}
291+
default:
292+
return hasInoutLifetimeDependence(decl);
281293
}
282-
return false;
283294
}
284295

285296
UNINTERESTING_FEATURE(DynamicActorIsolation)

0 commit comments

Comments
 (0)