Skip to content

Commit a7d3fd9

Browse files
committed
Java: Final rewrites to get things to compile
The equivalence relation needed for range analysis is now on underlying `ExprParent`s, as `BasicBlock` is now an IPA type and ids are opaque.
1 parent 3a7cf69 commit a7d3fd9

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

+7-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ module ControlFlow {
160160
result = this.asStmt().getLocation() or
161161
result = this.(ExitNode).getEnclosingCallable().getLocation()
162162
}
163+
164+
ExprParent getAstNode() {
165+
result = this.asExpr() or
166+
result = this.asStmt() or
167+
this = TExitNode(result)
168+
}
163169
}
164170

165171
class ExitNode extends Node, TExitNode { }
@@ -754,7 +760,7 @@ private module ControlFlowGraphImpl {
754760
or
755761
result.asExpr() = n and n instanceof WhenExpr
756762
or
757-
result.asExpr() = n and n instanceof WhenBranch
763+
result.asStmt() = n and n instanceof WhenBranch
758764
or
759765
result.asExpr() = n and n instanceof StmtExpr
760766
or

java/ql/lib/semmle/code/java/dataflow/RangeAnalysis.qll

+4-2
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,11 @@ module Sem implements Semantic {
211211

212212
BasicBlock getABasicBlockSuccessor(BasicBlock bb) { result = bb.getABBSuccessor() }
213213

214-
private predicate id(BasicBlock x, BasicBlock y) { x = y }
214+
private predicate id(ExprParent x, ExprParent y) { x = y }
215215

216-
private predicate idOf(BasicBlock x, int y) = equivalenceRelation(id/2)(x, y)
216+
private predicate idOfAst(ExprParent x, int y) = equivalenceRelation(id/2)(x, y)
217+
218+
private predicate idOf(BasicBlock x, int y) { idOfAst(x.getAstNode(), y) }
217219

218220
int getBlockId1(BasicBlock bb) { idOf(bb, result) }
219221

java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/ModulusAnalysisSpecific.qll

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,5 @@ module Private {
133133

134134
predicate ssaUpdateStep = RU::ssaUpdateStep/3;
135135

136-
Expr getABasicBlockExpr(BasicBlock bb) { result = bb.getANode() }
136+
Expr getABasicBlockExpr(BasicBlock bb) { result = bb.getANode().asExpr() }
137137
}

java/ql/lib/semmle/code/java/dataflow/internal/rangeanalysis/SsaReadPositionSpecific.qll

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ class BasicBlock = BB::BasicBlock;
1515
/** Gets a basic block in which SSA variable `v` is read. */
1616
BasicBlock getAReadBasicBlock(SsaVariable v) { result = v.getAUse().getBasicBlock() }
1717

18-
private predicate id(BasicBlock x, BasicBlock y) { x = y }
18+
private predicate id(BB::ExprParent x, BB::ExprParent y) { x = y }
1919

20-
private predicate idOf(BasicBlock x, int y) = equivalenceRelation(id/2)(x, y)
20+
private predicate idOfAst(BB::ExprParent x, int y) = equivalenceRelation(id/2)(x, y)
21+
22+
private predicate idOf(BasicBlock x, int y) { idOfAst(x.getAstNode(), y) }
2123

2224
private int getId(BasicBlock bb) { idOf(bb, result) }
2325

0 commit comments

Comments
 (0)