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

Skip to content

Commit db8d718

Browse files
committed
Fix CFG construction of ExprStmt and StmtExpr
1 parent fb77ad1 commit db8d718

7 files changed

Lines changed: 8 additions & 24 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,8 @@ private module ControlFlowGraphImpl {
909909
)
910910
or
911911
// the last node in an `ExprStmt` is the last node in the expression
912-
last(n.(ExprStmt).getExpr(), last, completion) and completion = NormalCompletion()
912+
last(n.(ExprStmt).getExpr(), last, completion) and
913+
completion instanceof NormalOrBooleanCompletion
913914
or
914915
// the last node in a `StmtExpr` is the last node in the statement
915916
last(n.(StmtExpr).getStmt(), last, completion)
@@ -1232,9 +1233,9 @@ private module ControlFlowGraphImpl {
12321233
n = synch and result = first(synch.getBlock())
12331234
)
12341235
or
1235-
result = first(n.(ExprStmt).getExpr()) and completion = NormalCompletion()
1236+
result = first(n.(ExprStmt).getExpr()) and completion instanceof NormalOrBooleanCompletion
12361237
or
1237-
result = first(n.(StmtExpr).getStmt()) and completion = NormalCompletion()
1238+
result = first(n.(StmtExpr).getStmt()) and completion instanceof NormalOrBooleanCompletion
12381239
or
12391240
result = first(n.(LabeledStmt).getStmt()) and completion = NormalCompletion()
12401241
or

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@
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:100:1:110:1 | fn |
45-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
46-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |
47-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
48-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
49-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:27:109:5 | { ... } |
5044
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
5145
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
5246
| 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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
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 | { ... } |
27+
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |
2628
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
2729
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |
2830
| Test.kt:101:33:103:5 | { ... } | Test.kt:100:1:110:1 | fn |

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@
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 | file://:0:0:0:0 | <none> | <none> |
191+
| Test.kt:101:22:101:30 | false | BooleanLiteral | Test.kt:101:33:103:5 | { ... } | BlockStmt |
192+
| Test.kt:101:22:101:30 | false | BooleanLiteral | Test.kt:105:5:109:5 | <Expr>; | ExprStmt |
192193
| Test.kt:101:22:101:30 | true | BooleanLiteral | Test.kt:101:22:101:30 | <Expr>; | ExprStmt |
193194
| Test.kt:101:27:101:30 | null | NullLiteral | Test.kt:101:22:101:30 | ... (value equals) ... | ValueEQExpr |
194195
| Test.kt:101:33:103:5 | { ... } | BlockStmt | Test.kt:102:15:102:25 | new Exception(...) | ClassInstanceExpr |

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,6 @@
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 ... |
548-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |
549-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:9:107:5 | ... -> ... |
550-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
551-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:106:9:106:29 | <Expr>; |
552-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
553-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:27:109:5 | { ... } |
554-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:108:9:108:29 | <Expr>; |
555546
| Test.kt:101:33:103:5 | { ... } | Test.kt:102:9:102:25 | throw ... |
556547
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:9:107:5 | ... -> ... |
557548
| 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: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@
210210
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:100:25:110:1 | { ... } |
211211
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:101:5:103:5 | ... -> ... |
212212
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:101:5:103:5 | <Expr>; |
213-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:100:25:110:1 | { ... } |
214-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:5:103:5 | ... -> ... |
215-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:5:103:5 | <Expr>; |
216-
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:9:101:30 | ... -> ... |
217213
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:22:101:30 | ... -> ... |
218214
| Test.kt:102:9:102:25 | throw ... | Test.kt:101:33:103:5 | { ... } |
219215
| Test.kt:105:9:107:5 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
| Test.kt:8:16:8:24 | ... (value not-equals) ... | This check is useless, $@ cannot be null here, since it is guarded by $@. | Test.kt:8:16:8:16 | y | y | Test.kt:2:22:2:30 | ... (value equals) ... | ... (value equals) ... |

0 commit comments

Comments
 (0)