Fix CFG construction of ExprStmt and StmtExpr

This commit is contained in:
Tamas Vajk
2022-04-07 10:35:48 +02:00
committed by Ian Lynagh
parent 81cb81366b
commit 8282e57db5
7 changed files with 8 additions and 24 deletions

View File

@@ -909,7 +909,8 @@ private module ControlFlowGraphImpl {
)
or
// the last node in an `ExprStmt` is the last node in the expression
last(n.(ExprStmt).getExpr(), last, completion) and completion = NormalCompletion()
last(n.(ExprStmt).getExpr(), last, completion) and
completion instanceof NormalOrBooleanCompletion
or
// the last node in a `StmtExpr` is the last node in the statement
last(n.(StmtExpr).getStmt(), last, completion)
@@ -1232,9 +1233,9 @@ private module ControlFlowGraphImpl {
n = synch and result = first(synch.getBlock())
)
or
result = first(n.(ExprStmt).getExpr()) and completion = NormalCompletion()
result = first(n.(ExprStmt).getExpr()) and completion instanceof NormalOrBooleanCompletion
or
result = first(n.(StmtExpr).getStmt()) and completion = NormalCompletion()
result = first(n.(StmtExpr).getStmt()) and completion instanceof NormalOrBooleanCompletion
or
result = first(n.(LabeledStmt).getStmt()) and completion = NormalCompletion()
or

View File

@@ -41,12 +41,6 @@
| Test.kt:100:25:110:1 | { ... } | Test.kt:105:20:107:5 | { ... } |
| Test.kt:100:25:110:1 | { ... } | Test.kt:107:16:109:5 | ... -> ... |
| Test.kt:100:25:110:1 | { ... } | Test.kt:107:27:109:5 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:100:1:110:1 | fn |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:27:109:5 | { ... } |
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:107:27:109:5 | { ... } |

View File

@@ -23,6 +23,8 @@
| Test.kt:95:4:97:2 | catch (...) | Test.kt:91:1:98:1 | t2 |
| Test.kt:100:25:110:1 | { ... } | Test.kt:101:22:101:30 | ... -> ... |
| Test.kt:100:25:110:1 | { ... } | Test.kt:101:22:101:30 | <Expr>; |
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:101:33:103:5 | { ... } |
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |
| Test.kt:101:33:103:5 | { ... } | Test.kt:100:1:110:1 | fn |

View File

@@ -188,7 +188,8 @@
| Test.kt:101:22:101:30 | ... -> ... | WhenBranch | Test.kt:101:22:101:30 | true | BooleanLiteral |
| Test.kt:101:22:101:30 | <Expr>; | ExprStmt | Test.kt:101:22:101:22 | y | VarAccess |
| Test.kt:101:22:101:30 | <Expr>; | ExprStmt | Test.kt:101:22:101:30 | false | BooleanLiteral |
| Test.kt:101:22:101:30 | false | BooleanLiteral | file://:0:0:0:0 | <none> | <none> |
| Test.kt:101:22:101:30 | false | BooleanLiteral | Test.kt:101:33:103:5 | { ... } | BlockStmt |
| Test.kt:101:22:101:30 | false | BooleanLiteral | Test.kt:105:5:109:5 | <Expr>; | ExprStmt |
| Test.kt:101:22:101:30 | true | BooleanLiteral | Test.kt:101:22:101:30 | <Expr>; | ExprStmt |
| Test.kt:101:27:101:30 | null | NullLiteral | Test.kt:101:22:101:30 | ... (value equals) ... | ValueEQExpr |
| Test.kt:101:33:103:5 | { ... } | BlockStmt | Test.kt:102:15:102:25 | new Exception(...) | ClassInstanceExpr |

View File

@@ -543,15 +543,6 @@
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:107:27:109:5 | { ... } |
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:108:9:108:29 | <Expr>; |
| Test.kt:101:22:101:30 | ... -> ... | Test.kt:101:22:101:30 | <Expr>; |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:33:103:5 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:102:9:102:25 | throw ... |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:5:109:5 | <Expr>; |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:9:107:5 | ... -> ... |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:105:20:107:5 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:106:9:106:29 | <Expr>; |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:16:109:5 | ... -> ... |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:107:27:109:5 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:108:9:108:29 | <Expr>; |
| Test.kt:101:33:103:5 | { ... } | Test.kt:102:9:102:25 | throw ... |
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:9:107:5 | ... -> ... |
| Test.kt:105:5:109:5 | <Expr>; | Test.kt:105:20:107:5 | { ... } |

View File

@@ -210,10 +210,6 @@
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:100:25:110:1 | { ... } |
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:101:5:103:5 | ... -> ... |
| Test.kt:101:9:101:30 | ... -> ... | Test.kt:101:5:103:5 | <Expr>; |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:100:25:110:1 | { ... } |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:5:103:5 | ... -> ... |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:5:103:5 | <Expr>; |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:9:101:30 | ... -> ... |
| Test.kt:101:22:101:30 | <Expr>; | Test.kt:101:22:101:30 | ... -> ... |
| Test.kt:102:9:102:25 | throw ... | Test.kt:101:33:103:5 | { ... } |
| Test.kt:105:9:107:5 | ... -> ... | Test.kt:105:5:109:5 | <Expr>; |

View File

@@ -1 +0,0 @@
| 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) ... |