Merge pull request #9269 from igfoo/igfoo/cfg

Kotlin: Fix CFG
This commit is contained in:
Ian Lynagh
2022-05-24 10:53:00 +01:00
committed by GitHub
5 changed files with 9 additions and 9 deletions

View File

@@ -286,7 +286,7 @@ private module ControlFlowGraphImpl {
* That is, contexts where the control-flow edges depend on `value` given that `b` ends
* with a `booleanCompletion(value, _)`.
*/
private predicate inBooleanContext(Expr b) {
private predicate inBooleanContext(ControlFlowNode b) {
exists(LogicExpr logexpr |
logexpr.(BinaryExpr).getLeftOperand() = b
or
@@ -316,6 +316,10 @@ private module ControlFlowGraphImpl {
inBooleanContext(whenexpr) and
whenexpr.getBranch(_).getAResult() = b
)
or
inBooleanContext(b.(ExprStmt).getExpr())
or
inBooleanContext(b.(StmtExpr).getStmt())
}
/**
@@ -907,7 +911,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)

View File

@@ -53,5 +53,4 @@
| Test.kt:118:37:124:1 | { ... } | Test.kt:121:9:121:9 | <Expr>; |
| Test.kt:118:37:124:1 | { ... } | Test.kt:122:12:122:16 | ... -> ... |
| Test.kt:118:37:124:1 | { ... } | Test.kt:123:8:123:10 | { ... } |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:118:1:124:1 | fn_when |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:123:8:123:10 | { ... } |

View File

@@ -41,4 +41,5 @@
| Test.kt:118:37:124:1 | { ... } | Test.kt:122:12:122:16 | ... -> ... |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:118:1:124:1 | fn_when |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:123:8:123:10 | { ... } |
| Test.kt:122:12:122:16 | ... -> ... | Test.kt:118:1:124:1 | fn_when |
| Test.kt:123:8:123:10 | { ... } | Test.kt:118:1:124:1 | fn_when |

View File

@@ -1,5 +1,4 @@
missingSuccessor
| Test.kt:122:12:122:16 | false |
#select
| Test.kt:0:0:0:0 | TestKt | Class | file://:0:0:0:0 | <none> | <none> |
| Test.kt:3:1:80:1 | Test | Class | file://:0:0:0:0 | <none> | <none> |
@@ -257,6 +256,6 @@ missingSuccessor
| Test.kt:121:9:121:9 | y | VarAccess | Test.kt:123:8:123:10 | { ... } | BlockStmt |
| Test.kt:122:12:122:16 | ... -> ... | WhenBranch | Test.kt:122:12:122:16 | true | BooleanLiteral |
| Test.kt:122:12:122:16 | <Expr>; | ExprStmt | Test.kt:122:12:122:16 | false | BooleanLiteral |
| Test.kt:122:12:122:16 | false | BooleanLiteral | file://:0:0:0:0 | <none> | <none> |
| Test.kt:122:12:122:16 | false | BooleanLiteral | Test.kt:118:1:124:1 | fn_when | Method |
| Test.kt:122:12:122:16 | true | BooleanLiteral | Test.kt:122:12:122:16 | <Expr>; | ExprStmt |
| Test.kt:123:8:123:10 | { ... } | BlockStmt | Test.kt:118:1:124:1 | fn_when | Method |

View File

@@ -220,8 +220,4 @@
| Test.kt:121:4:121:9 | ... -> ... | Test.kt:118:37:124:1 | { ... } |
| Test.kt:121:4:121:9 | ... -> ... | Test.kt:119:2:123:12 | <Expr>; |
| Test.kt:121:4:121:9 | ... -> ... | Test.kt:120:3:123:10 | ... -> ... |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:118:37:124:1 | { ... } |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:119:2:123:12 | <Expr>; |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:120:3:123:10 | ... -> ... |
| Test.kt:121:9:121:9 | <Expr>; | Test.kt:121:4:121:9 | ... -> ... |
| Test.kt:122:12:122:16 | <Expr>; | Test.kt:122:12:122:16 | ... -> ... |