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

Skip to content

Commit b35b747

Browse files
committed
Revert "Fix CFG construction of ExprStmt and StmtExpr"
This reverts commit db8d718. It broke ql/java/ql/test/library-tests/successors/TestDeclarations
1 parent d2f6871 commit b35b747

7 files changed

Lines changed: 24 additions & 8 deletions

File tree

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ 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
913-
completion instanceof NormalOrBooleanCompletion
912+
last(n.(ExprStmt).getExpr(), last, completion) and completion = NormalCompletion()
914913
or
915914
// the last node in a `StmtExpr` is the last node in the statement
916915
last(n.(StmtExpr).getStmt(), last, completion)
@@ -1233,9 +1232,9 @@ private module ControlFlowGraphImpl {
12331232
n = synch and result = first(synch.getBlock())
12341233
)
12351234
or
1236-
result = first(n.(ExprStmt).getExpr()) and completion instanceof NormalOrBooleanCompletion
1235+
result = first(n.(ExprStmt).getExpr()) and completion = NormalCompletion()
12371236
or
1238-
result = first(n.(StmtExpr).getStmt()) and completion instanceof NormalOrBooleanCompletion
1237+
result = first(n.(StmtExpr).getStmt()) and completion = NormalCompletion()
12391238
or
12401239
result = first(n.(LabeledStmt).getStmt()) and completion = NormalCompletion()
12411240
or

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
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 | { ... } |
4450
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
4551
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
4652
| 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +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 | { ... } |
27-
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |
2826
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
2927
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |
3028
| 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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@
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 |
192-
| Test.kt:101:22:101:30 | false | BooleanLiteral | Test.kt:105:5:109:5 | <Expr>; | ExprStmt |
191+
| Test.kt:101:22:101:30 | false | BooleanLiteral | file://:0:0:0:0 | <none> | <none> |
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 |
195194
| 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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,15 @@
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>; |
546555
| Test.kt:101:33:103:5 | { ... } | Test.kt:102:9:102:25 | throw ... |
547556
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:9:107:5 | ... -> ... |
548557
| 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
@@ -210,6 +210,10 @@
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 | ... -> ... |
213217
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:22:101:30 | ... -> ... |
214218
| Test.kt:102:9:102:25 | throw ... | Test.kt:101:33:103:5 | { ... } |
215219
| Test.kt:105:9:107:5 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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)