Skip to content

Commit 42da7c6

Browse files
committed
Kotlin: Fix CFG
1 parent 4eddb62 commit 42da7c6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ private module ControlFlowGraphImpl {
286286
* That is, contexts where the control-flow edges depend on `value` given that `b` ends
287287
* with a `booleanCompletion(value, _)`.
288288
*/
289-
private predicate inBooleanContext(Expr b) {
289+
private predicate inBooleanContext(ControlFlowNode b) {
290290
exists(LogicExpr logexpr |
291291
logexpr.(BinaryExpr).getLeftOperand() = b
292292
or
@@ -316,6 +316,10 @@ private module ControlFlowGraphImpl {
316316
inBooleanContext(whenexpr) and
317317
whenexpr.getBranch(_).getAResult() = b
318318
)
319+
or
320+
inBooleanContext(b.(ExprStmt).getExpr())
321+
or
322+
inBooleanContext(b.(StmtExpr).getStmt())
319323
}
320324

321325
/**
@@ -907,7 +911,7 @@ private module ControlFlowGraphImpl {
907911
)
908912
or
909913
// the last node in an `ExprStmt` is the last node in the expression
910-
last(n.(ExprStmt).getExpr(), last, completion) and completion = NormalCompletion()
914+
last(n.(ExprStmt).getExpr(), last, completion) and completion instanceof NormalOrBooleanCompletion
911915
or
912916
// the last node in a `StmtExpr` is the last node in the statement
913917
last(n.(StmtExpr).getStmt(), last, completion)

0 commit comments

Comments
 (0)