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