Skip to content
Merged
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
19 changes: 16 additions & 3 deletions server/ql/java/tools/src/PrintCFG/PrintCFG.ql
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,26 @@ import java
import semmle.code.java.ControlFlowGraph

/**
* Configuration for PrintCFG that outputs all CFG nodes and edges.
* Holds if the node is an exit-related CFG node.
* These nodes are excluded from the output because their ordering
* is non-deterministic across CodeQL CLI versions.
*/
private predicate isExitNode(ControlFlow::Node node) {
node.toString().matches("%Exit")
}

/**
* Configuration for PrintCFG that outputs all CFG nodes and edges,
* excluding exit nodes for deterministic output.
*/
query predicate nodes(ControlFlow::Node node, string property, string value) {
property = "semmle.label" and
value = node.toString()
value = node.toString() and
not isExitNode(node)
}

query predicate edges(ControlFlow::Node pred, ControlFlow::Node succ) {
pred.getASuccessor() = succ
pred.getASuccessor() = succ and
not isExitNode(pred) and
not isExitNode(succ)
}
30 changes: 0 additions & 30 deletions server/ql/java/tools/test/PrintCFG/PrintCFG.expected
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Example1.java:
#-----| -> super(...)

# 3| super(...)
#-----| -> Normal Exit

# 5| { ... }
#-----| -> if (...)
Expand Down Expand Up @@ -48,7 +47,6 @@ Example1.java:
#-----| -> 1

# 20| return ...
#-----| -> Normal Exit

# 23| { ... }
#-----| -> <Expr>;
Expand All @@ -60,19 +58,16 @@ Example1.java:
#-----| -> 0

# 29| return ...
#-----| -> Normal Exit

# 30| case ...
#-----| -> 1

# 31| return ...
#-----| -> Normal Exit

# 32| default
#-----| -> value

# 33| return ...
#-----| -> Normal Exit

# 6| ... > ...
#-----| -> { ... }
Expand Down Expand Up @@ -110,7 +105,6 @@ Example1.java:

# 12| ... < ...
#-----| -> { ... }
#-----| -> Normal Exit

# 12| ...++
#-----| -> i
Expand Down Expand Up @@ -190,27 +184,3 @@ Example1.java:

# 33| 2
#-----| -> ... * ...

# 3| Exceptional Exit
#-----| -> Exit

# 3| Normal Exit
#-----| -> Exit

# 5| Exceptional Exit
#-----| -> Exit

# 5| Normal Exit
#-----| -> Exit

# 18| Exceptional Exit
#-----| -> Exit

# 18| Normal Exit
#-----| -> Exit

# 3| Exit

# 5| Exit

# 18| Exit