Skip to content

Commit 959ff4f

Browse files
committed
unified: Simplify getChild
This turned out not to be needed for the fix I was working on, but it seemed like a worthwhile simplification to land anyway.
1 parent d0d4d7c commit 959ff4f

1 file changed

Lines changed: 6 additions & 13 deletions

File tree

‎unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,21 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
7676
or
7777
result = n.(LogicalAndRoot).getNthLeaf(index)
7878
or
79-
index = 0 and
80-
relocatedClassMember(n, result)
81-
}
82-
83-
/**
84-
* Holds if `member` is moved onto a child of `className` instead of the class itself,
85-
* so the member name is not in scope in the base types and type parameter constraints.
86-
*/
87-
private predicate relocatedClassMember(Identifier className, Member member) {
79+
// Move members under the name node of its class, so the member name is not in scope
80+
// in the base types and type parameter constraints.
8881
exists(ClassLikeDeclaration cls |
89-
className = cls.getNameNode() and
90-
member = cls.getAMember()
82+
n = cls.getNameNode() and
83+
result = cls.getAMember() and
84+
index = 0
9185
)
9286
}
9387

9488
AstNode getChild(AstNode n, int index) {
9589
result = getChild1(n, index)
9690
or
97-
not exists(getChild1(n, _)) and
91+
not result = getChild1(_, _) and
9892
not n instanceof LogicalAndExpr and // also ignore intermediate nodes within a 'logical and' tree
9993
not n instanceof GuardIfStmt and
100-
not relocatedClassMember(_, result) and
10194
index = result.getParentIndex() and
10295
result = n.getAFieldOrChild()
10396
}

0 commit comments

Comments
 (0)