Skip to content

Commit eabb5c7

Browse files
committed
Swift: Respond to PR comments.
1 parent db0498e commit eabb5c7

File tree

1 file changed

+9
-1
lines changed
  • swift/ql/lib/codeql/swift/controlflow/internal

1 file changed

+9
-1
lines changed

swift/ql/lib/codeql/swift/controlflow/internal/Scope.qll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,19 @@ class Scope extends AstNode instanceof Scope::Range {
2828

2929
cached
3030
private module Cached {
31-
private AstNode getParentOfAstStep(Element e) {
31+
/**
32+
* Gets the immediate parent of a non-`AstNode` element `e`.
33+
*
34+
* We restrict `e` to be a non-`AstNode` to skip past non-`AstNode` in
35+
* the transitive closure computation in `getParentOfAst`. This is
36+
* necessary because the parent of an `AstNode` is not necessarily an `AstNode`.
37+
*/
38+
private Element getParentOfAstStep(Element e) {
3239
not e instanceof AstNode and
3340
result = getImmediateParent(e)
3441
}
3542

43+
/** Gets the nearest enclosing parent of `ast` that is an `AstNode`. */
3644
cached
3745
AstNode getParentOfAst(AstNode ast) { result = getParentOfAstStep*(getImmediateParent(ast)) }
3846
}

0 commit comments

Comments
 (0)