Skip to content

Commit ba9d21e

Browse files
authored
Merge pull request github#17970 from owen-mc/java/lightweight-IR-layer
Java: IPA the CFG (second try)
2 parents 0f5786e + 5b57511 commit ba9d21e

File tree

108 files changed

+611
-603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+611
-603
lines changed

java/ql/consistency-queries/cfgDeadEnds.ql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import java
2-
import semmle.code.java.ControlFlowGraph
32

4-
predicate shouldBeDeadEnd(ControlFlowNode n) {
3+
predicate shouldBeDeadEnd(ExprParent n) {
54
n instanceof BreakStmt and n.getFile().isKotlinSourceFile() // TODO
65
or
76
n instanceof Interface // TODO
@@ -55,8 +54,11 @@ predicate shouldBeDeadEnd(ControlFlowNode n) {
5554
n = any(ConstCase c).getValue(_) // TODO
5655
}
5756

58-
from ControlFlowNode n, string s
57+
from ControlFlowNode n, ExprParent astnode, string s
5958
where
60-
// TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n) and s = "expected dead end"
61-
not exists(n.getASuccessor()) and not shouldBeDeadEnd(n) and s = "unexpected dead end"
62-
select n, n.getPrimaryQlClasses(), s
59+
astnode = n.getAstNode() and
60+
// TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n.getAstNode()) and s = "expected dead end"
61+
not exists(n.getASuccessor()) and
62+
not shouldBeDeadEnd(astnode) and
63+
s = "unexpected dead end"
64+
select n, astnode.getPrimaryQlClasses(), s
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
category: breaking
3+
---
4+
* The class `ControlFlowNode` (and by extension `BasicBlock`) is no longer
5+
directly equatable to `Expr` and `Stmt`. Any queries that have been
6+
exploiting these equalities, for example by using casts, will need minor
7+
updates in order to fix any compilation errors. Conversions can be inserted
8+
in either direction depending on what is most convenient. Available
9+
conversions include `Expr.getControlFlowNode()`, `Stmt.getControlFlowNode()`,
10+
`ControlFlowNode.asExpr()`, `ControlFlowNode.asStmt()`, and
11+
`ControlFlowNode.asCall()`. Exit nodes were until now modelled as a
12+
`ControlFlowNode` equal to its enclosing `Callable`; these are now instead
13+
modelled by the class `ControlFlow::ExitNode`.

0 commit comments

Comments
 (0)