mirror of
https://github.com/github/codeql.git
synced 2026-02-20 08:53:49 +01:00
CFG: add AstNode for @in
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
private import codeql_ruby.AST
|
||||
private import codeql_ruby.ast.internal.Control
|
||||
private import codeql_ruby.controlflow.ControlFlowGraph
|
||||
private import ControlFlowGraphImpl
|
||||
private import NonReturning
|
||||
@@ -54,7 +53,7 @@ private predicate nestedEnsureCompletion(Completion outer, int nestLevel) {
|
||||
|
||||
pragma[noinline]
|
||||
private predicate completionIsValidForStmt(AstNode n, Completion c) {
|
||||
n instanceof In::Range and
|
||||
n instanceof InRange and
|
||||
c instanceof EmptinessCompletion
|
||||
or
|
||||
n instanceof BreakStmt and
|
||||
|
||||
@@ -31,7 +31,8 @@
|
||||
* caught up by its surrounding loop and turned into a `NormalCompletion`.
|
||||
*/
|
||||
|
||||
private import codeql_ruby.AST as AST
|
||||
private import codeql_ruby.ast.internal.AST as ASTInternal
|
||||
private import codeql_ruby.ast.internal.Control as Control
|
||||
private import codeql_ruby.ast.internal.TreeSitter::Generated
|
||||
private import AstNodes
|
||||
private import codeql_ruby.ast.internal.Variable
|
||||
@@ -307,6 +308,18 @@ abstract private class PreOrderTree extends ControlFlowTree {
|
||||
final override predicate first(AstNode first) { first = this }
|
||||
}
|
||||
|
||||
class InRange extends ASTInternal::AstNode::Range, @in {
|
||||
final override string toString() { result = "In" }
|
||||
}
|
||||
|
||||
class ForRange extends Control::ForExpr::Range, @for {
|
||||
override predicate child(string label, ASTInternal::AstNode::Range child) {
|
||||
Control::ForExpr::Range.super.child(label, child)
|
||||
or
|
||||
label = "<in>" and this.(AstNode).getAFieldOrChild().(In) = child
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove this predicate
|
||||
predicate isValidFor(Completion c, ControlFlowTree node) {
|
||||
c instanceof SimpleCompletion and isHidden(node)
|
||||
|
||||
Reference in New Issue
Block a user