mirror of
https://github.com/github/codeql.git
synced 2026-04-24 08:15:14 +02:00
Swift: Fix CFG for key-path expressions.
This commit is contained in:
@@ -58,7 +58,7 @@ module CfgScope {
|
||||
}
|
||||
|
||||
private class KeyPathScope extends Range_ instanceof KeyPathExpr {
|
||||
AstControlFlowTree tree;
|
||||
KeyPathControlFlowTree tree;
|
||||
|
||||
KeyPathScope() { tree.getAst() = this }
|
||||
|
||||
@@ -76,6 +76,12 @@ module CfgScope {
|
||||
|
||||
final override predicate exit(ControlFlowElement last, Completion c) { last(tree, last, c) }
|
||||
}
|
||||
|
||||
private class KeyPathControlFlowTree extends StandardPostOrderTree, KeyPathElement {
|
||||
final override ControlFlowElement getChildElement(int i) {
|
||||
result.asAstNode() = expr.getComponent(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Holds if `first` is first executed when entering `scope`. */
|
||||
@@ -88,6 +94,14 @@ predicate succExit(CfgScope::Range_ scope, ControlFlowElement last, Completion c
|
||||
scope.exit(last, c)
|
||||
}
|
||||
|
||||
private class KeyPathComponentTree extends AstStandardPostOrderTree {
|
||||
override KeyPathComponent ast;
|
||||
|
||||
final override ControlFlowElement getChildElement(int i) {
|
||||
result.asAstNode() = ast.getSubscriptArgument(i).getExpr().getFullyConverted()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Control-flow for statements.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user