Skip to content

Commit cd499e7

Browse files
committed
Java: Don't use BooleanSuccessor label for successors of boolean literals.
1 parent 4f67031 commit cd499e7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

java/ql/lib/semmle/code/java/controlflow/BasicBlocks.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,14 @@ private module Input implements BB::InputSig<Location> {
1919
/** Gets the CFG scope in which this node occurs. */
2020
CfgScope nodeGetCfgScope(Node node) { node.getEnclosingCallable() = result }
2121

22+
private Node getATrivialBooleanSuccessor(Node node) {
23+
result = unique(Node n | n = node.(ConditionNode).getABranchSuccessor(_)) and
24+
node.asExpr() instanceof BooleanLiteral
25+
}
26+
2227
private Node getASpecificSuccessor(Node node, SuccessorType t) {
23-
node.(ConditionNode).getABranchSuccessor(t.(BooleanSuccessor).getValue()) = result
28+
node.(ConditionNode).getABranchSuccessor(t.(BooleanSuccessor).getValue()) = result and
29+
not result = getATrivialBooleanSuccessor(node)
2430
or
2531
node.getAnExceptionSuccessor() = result and t instanceof ExceptionSuccessor
2632
}

0 commit comments

Comments
 (0)