From a30cfe28109f63456505fed8759900bd59a0028c Mon Sep 17 00:00:00 2001 From: Meghana Gupta Date: Fri, 4 Apr 2025 06:04:37 -0700 Subject: [PATCH] Fix printing @lifetime(&arg) for accessors in swiftinterface files --- lib/AST/FeatureSet.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/AST/FeatureSet.cpp b/lib/AST/FeatureSet.cpp index f876293661a9d..3f95a09dad2bc 100644 --- a/lib/AST/FeatureSet.cpp +++ b/lib/AST/FeatureSet.cpp @@ -272,15 +272,26 @@ static bool usesFeatureLifetimeDependence(Decl *decl) { } static bool usesFeatureInoutLifetimeDependence(Decl *decl) { - for (auto attr : decl->getAttrs().getAttributes()) { - for (auto source : attr->getLifetimeEntry()->getSources()) { - if (source.getParsedLifetimeDependenceKind() == - ParsedLifetimeDependenceKind::Inout) { - return true; + auto hasInoutLifetimeDependence = [](Decl *decl) { + for (auto attr : decl->getAttrs().getAttributes()) { + for (auto source : attr->getLifetimeEntry()->getSources()) { + if (source.getParsedLifetimeDependenceKind() == + ParsedLifetimeDependenceKind::Inout) { + return true; + } } } + return false; + }; + + switch (decl->getKind()) { + case DeclKind::Var: { + auto *var = cast(decl); + return llvm::any_of(var->getAllAccessors(), hasInoutLifetimeDependence); + } + default: + return hasInoutLifetimeDependence(decl); } - return false; } UNINTERESTING_FEATURE(DynamicActorIsolation)