|
| 1 | +/** |
| 2 | + * Provides an implementation of local (intraprocedural) control flow reachability. |
| 3 | + */ |
| 4 | +overlay[local?] |
| 5 | +module; |
| 6 | + |
| 7 | +import java |
| 8 | +private import codeql.controlflow.ControlFlow |
| 9 | +private import semmle.code.java.dataflow.SSA as SSA |
| 10 | +private import semmle.code.java.controlflow.Guards as Guards |
| 11 | + |
| 12 | +private module ControlFlowInput implements InputSig<Location, ControlFlowNode, BasicBlock> { |
| 13 | + private import java as J |
| 14 | + |
| 15 | + AstNode getEnclosingAstNode(ControlFlowNode node) { node.getAstNode() = result } |
| 16 | + |
| 17 | + class AstNode = ExprParent; |
| 18 | + |
| 19 | + AstNode getParent(AstNode node) { |
| 20 | + result = node.(Expr).getParent() or |
| 21 | + result = node.(Stmt).getParent() |
| 22 | + } |
| 23 | + |
| 24 | + class FinallyBlock extends AstNode { |
| 25 | + FinallyBlock() { any(TryStmt try).getFinally() = this } |
| 26 | + } |
| 27 | + |
| 28 | + class Expr = J::Expr; |
| 29 | + |
| 30 | + class SourceVariable = SSA::SsaSourceVariable; |
| 31 | + |
| 32 | + class SsaDefinition = SSA::SsaVariable; |
| 33 | + |
| 34 | + class SsaWriteDefinition extends SsaDefinition instanceof SSA::SsaExplicitUpdate { |
| 35 | + Expr getDefinition() { |
| 36 | + super.getDefiningExpr().(VariableAssign).getSource() = result or |
| 37 | + super.getDefiningExpr().(AssignOp) = result |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + class SsaPhiNode = SSA::SsaPhiNode; |
| 42 | + |
| 43 | + class SsaUncertainDefinition extends SsaDefinition instanceof SSA::SsaUncertainImplicitUpdate { |
| 44 | + SsaDefinition getPriorDefinition() { result = super.getPriorDef() } |
| 45 | + } |
| 46 | + |
| 47 | + class GuardValue = Guards::GuardValue; |
| 48 | + |
| 49 | + predicate ssaControlsBranchEdge(SsaDefinition def, BasicBlock bb1, BasicBlock bb2, GuardValue v) { |
| 50 | + Guards::Guards_v3::ssaControlsBranchEdge(def, bb1, bb2, v) |
| 51 | + } |
| 52 | + |
| 53 | + predicate ssaControls(SsaDefinition def, BasicBlock bb, GuardValue v) { |
| 54 | + Guards::Guards_v3::ssaControls(def, bb, v) |
| 55 | + } |
| 56 | + |
| 57 | + import Guards::Guards_v3::InternalUtil |
| 58 | +} |
| 59 | + |
| 60 | +module ControlFlow = Make<Location, Cfg, ControlFlowInput>; |
0 commit comments