Skip to content

Commit 6887212

Browse files
check for parent pattern bindings when the parent is a decl
1 parent f53a135 commit 6887212

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/AST/ASTWalker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
12411241
}
12421242

12431243
bool shouldSkip(Decl *D) {
1244-
if (isa<VarDecl>(D)) {
1244+
if (auto *VD = dyn_cast<VarDecl>(D)) {
12451245
// VarDecls are walked via their NamedPattern, ignore them if we encounter
12461246
// then in the few cases where they are also pushed outside as members.
12471247
// In all those cases we can walk them via the pattern binding decl.
@@ -1250,8 +1250,8 @@ class Traversal : public ASTVisitor<Traversal, Expr*, Stmt*,
12501250
if (Walker.Parent.getAsModule() &&
12511251
D->getDeclContext()->getParentSourceFile())
12521252
return true;
1253-
if (Decl *ParentD = Walker.Parent.getAsDecl())
1254-
return (!D->hasClangNode() && (isa<NominalTypeDecl>(ParentD) || isa<ExtensionDecl>(ParentD)));
1253+
if (Walker.Parent.getAsDecl() && VD->getParentPatternBinding())
1254+
return true;
12551255
auto walkerParentAsStmt = Walker.Parent.getAsStmt();
12561256
if (walkerParentAsStmt && isa<BraceStmt>(walkerParentAsStmt))
12571257
return true;

0 commit comments

Comments
 (0)