Skip to content

Commit

Permalink
Merge pull request #17970 from owen-mc/java/lightweight-IR-layer
Browse files Browse the repository at this point in the history
Java: IPA the CFG (second try)
  • Loading branch information
owen-mc authored Dec 10, 2024
2 parents 0f5786e + 5b57511 commit ba9d21e
Show file tree
Hide file tree
Showing 108 changed files with 611 additions and 603 deletions.
14 changes: 8 additions & 6 deletions java/ql/consistency-queries/cfgDeadEnds.ql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import java
import semmle.code.java.ControlFlowGraph

predicate shouldBeDeadEnd(ControlFlowNode n) {
predicate shouldBeDeadEnd(ExprParent n) {
n instanceof BreakStmt and n.getFile().isKotlinSourceFile() // TODO
or
n instanceof Interface // TODO
Expand Down Expand Up @@ -55,8 +54,11 @@ predicate shouldBeDeadEnd(ControlFlowNode n) {
n = any(ConstCase c).getValue(_) // TODO
}

from ControlFlowNode n, string s
from ControlFlowNode n, ExprParent astnode, string s
where
// TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n) and s = "expected dead end"
not exists(n.getASuccessor()) and not shouldBeDeadEnd(n) and s = "unexpected dead end"
select n, n.getPrimaryQlClasses(), s
astnode = n.getAstNode() and
// TODO: exists(n.getASuccessor()) and shouldBeDeadEnd(n.getAstNode()) and s = "expected dead end"
not exists(n.getASuccessor()) and
not shouldBeDeadEnd(astnode) and
s = "unexpected dead end"
select n, astnode.getPrimaryQlClasses(), s
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
category: breaking
---
* The class `ControlFlowNode` (and by extension `BasicBlock`) is no longer
directly equatable to `Expr` and `Stmt`. Any queries that have been
exploiting these equalities, for example by using casts, will need minor
updates in order to fix any compilation errors. Conversions can be inserted
in either direction depending on what is most convenient. Available
conversions include `Expr.getControlFlowNode()`, `Stmt.getControlFlowNode()`,
`ControlFlowNode.asExpr()`, `ControlFlowNode.asStmt()`, and
`ControlFlowNode.asCall()`. Exit nodes were until now modelled as a
`ControlFlowNode` equal to its enclosing `Callable`; these are now instead
modelled by the class `ControlFlow::ExitNode`.
Loading

0 comments on commit ba9d21e

Please sign in to comment.