Skip to content

Commit 62839d1

Browse files
committed
[ASTScope] Avoid treating @abi bindings as local
Such bindings may have a local decl context, but their scope shouldn't extend past the `@abi` attribute.
1 parent b45b039 commit 62839d1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/AST/ASTScopeCreation.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,11 +666,16 @@ ScopeCreator::addPatternBindingToScopeTree(PatternBindingDecl *patternBinding,
666666
if (auto *var = patternBinding->getSingleVar())
667667
addChildrenForKnownAttributes(var, parentScope);
668668

669+
// Check to see if we have a local binding. Note we need to exclude bindings
670+
// in `@abi` attributes here since they may be in a local DeclContext, but
671+
// their scope shouldn't extend past the attribute.
669672
bool isLocalBinding = false;
670-
for (auto i : range(patternBinding->getNumPatternEntries())) {
671-
if (auto *varDecl = patternBinding->getAnchoringVarDecl(i)) {
672-
isLocalBinding = varDecl->getDeclContext()->isLocalContext();
673-
break;
673+
if (!isa<ABIAttributeScope>(parentScope)) {
674+
for (auto i : range(patternBinding->getNumPatternEntries())) {
675+
if (auto *varDecl = patternBinding->getAnchoringVarDecl(i)) {
676+
isLocalBinding = varDecl->getDeclContext()->isLocalContext();
677+
break;
678+
}
674679
}
675680
}
676681

0 commit comments

Comments
 (0)