Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java: IPA the CFG (second try) #17970

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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