Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 037d66d

Browse files
tamasvajkigfoo
authored andcommitted
Fix ExprStmt and StmtExpr in Boolean context
1 parent 3856912 commit 037d66d

6 files changed

Lines changed: 12 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
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
/**

java/ql/test/kotlin/library-tests/controlflow/basic/bbStrictDominance.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
| Test.kt:100:25:110:1 | { ... } | Test.kt:105:20:107:5 | { ... } |
4242
| Test.kt:100:25:110:1 | { ... } | Test.kt:107:16:109:5 | ... -> ... |
4343
| Test.kt:100:25:110:1 | { ... } | Test.kt:107:27:109:5 | { ... } |
44+
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
4445
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
4546
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
4647
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:107:27:109:5 | { ... } |

java/ql/test/kotlin/library-tests/controlflow/basic/bbSuccessor.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
| Test.kt:95:4:97:2 | catch (...) | Test.kt:91:1:98:1 | t2 |
2424
| Test.kt:100:25:110:1 | { ... } | Test.kt:101:22:101:30 | ... -> ... |
2525
| Test.kt:100:25:110:1 | { ... } | Test.kt:101:22:101:30 | <Expr>; |
26-
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:101:33:103:5 | { ... } |
2726
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |
2827
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
2928
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |

java/ql/test/kotlin/library-tests/controlflow/basic/getASuccessor.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@
188188
| Test.kt:101:22:101:30 | ... -> ... | WhenBranch | Test.kt:101:22:101:30 | true | BooleanLiteral |
189189
| Test.kt:101:22:101:30 | <Expr>; | ExprStmt | Test.kt:101:22:101:22 | y | VarAccess |
190190
| Test.kt:101:22:101:30 | <Expr>; | ExprStmt | Test.kt:101:22:101:30 | false | BooleanLiteral |
191-
| Test.kt:101:22:101:30 | false | BooleanLiteral | Test.kt:101:33:103:5 | { ... } | BlockStmt |
192191
| Test.kt:101:22:101:30 | false | BooleanLiteral | Test.kt:105:5:109:5 | <Expr>; | ExprStmt |
193192
| Test.kt:101:22:101:30 | true | BooleanLiteral | Test.kt:101:22:101:30 | <Expr>; | ExprStmt |
194193
| Test.kt:101:27:101:30 | null | NullLiteral | Test.kt:101:22:101:30 | ... (value equals) ... | ValueEQExpr |

java/ql/test/kotlin/library-tests/controlflow/basic/strictDominance.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,8 @@
543543
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:107:27:109:5 | { ... } |
544544
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:108:9:108:29 | <Expr>; |
545545
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:101:22:101:30 | <Expr>; |
546+
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
547+
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:102:9:102:25 | throw ... |
546548
| Test.kt:101:33:103:5 | { ... } | Test.kt:102:9:102:25 | throw ... |
547549
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:9:107:5 | ... -> ... |
548550
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:20:107:5 | { ... } |

java/ql/test/kotlin/library-tests/controlflow/basic/strictPostDominance.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@
212212
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:101:5:103:5 | <Expr>; |
213213
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:22:101:30 | ... -> ... |
214214
| Test.kt:102:9:102:25 | throw ... | Test.kt:101:33:103:5 | { ... } |
215+
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:101:22:101:30 | ... -> ... |
216+
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:101:22:101:30 | <Expr>; |
217+
| Test.kt:105:9:107:5 | ... -> ... | Test.kt:101:22:101:30 | ... -> ... |
218+
| Test.kt:105:9:107:5 | ... -> ... | Test.kt:101:22:101:30 | <Expr>; |
215219
| Test.kt:105:9:107:5 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |
216220
| Test.kt:106:9:106:29 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
217221
| Test.kt:108:9:108:29 | <Expr>; | Test.kt:107:27:109:5 | { ... } |

0 commit comments

Comments
 (0)