mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Extract simple in-place operators
Complex in-place operators (someFieldOrArrayCell += e) get a harder-to-parse lowering which needs to be intercepted at the IrBlock level
This commit is contained in:
committed by
Ian Lynagh
parent
2fb54de269
commit
8af0f26411
@@ -61,11 +61,9 @@
|
||||
| Test.kt:31:8:31:9 | 60 | Test.kt:31:4:31:4 | ...=... |
|
||||
| Test.kt:32:4:32:4 | <Expr>; | Test.kt:32:8:32:9 | 10 |
|
||||
| Test.kt:32:8:32:9 | 10 | Test.kt:32:4:32:4 | ...=... |
|
||||
| Test.kt:35:3:35:3 | ...=... | Test.kt:38:3:41:3 | while (...) |
|
||||
| Test.kt:35:3:35:3 | ...+=... | Test.kt:38:3:41:3 | while (...) |
|
||||
| Test.kt:35:3:35:3 | <Expr>; | Test.kt:35:3:35:3 | z |
|
||||
| Test.kt:35:3:35:3 | z | Test.kt:35:8:35:8 | x |
|
||||
| Test.kt:35:3:35:8 | plus(...) | Test.kt:35:3:35:3 | ...=... |
|
||||
| Test.kt:35:8:35:8 | x | Test.kt:35:3:35:8 | plus(...) |
|
||||
| Test.kt:35:8:35:8 | x | Test.kt:35:3:35:3 | ...+=... |
|
||||
| Test.kt:38:3:41:3 | while (...) | Test.kt:38:10:38:10 | x |
|
||||
| Test.kt:38:10:38:10 | x | Test.kt:38:14:38:14 | 0 |
|
||||
| Test.kt:38:10:38:14 | ... > ... | Test.kt:38:17:41:3 | { ... } |
|
||||
@@ -87,19 +85,15 @@
|
||||
| Test.kt:40:4:40:6 | tmp0 | Test.kt:40:4:40:6 | <implicit coercion to unit> |
|
||||
| Test.kt:40:4:40:6 | tmp0 | Test.kt:40:4:40:6 | dec(...) |
|
||||
| Test.kt:40:4:40:6 | { ... } | Test.kt:40:4:40:4 | var ...; |
|
||||
| Test.kt:43:3:43:3 | ...=... | Test.kt:73:3:73:3 | <Expr>; |
|
||||
| Test.kt:43:3:43:3 | ...+=... | Test.kt:73:3:73:3 | <Expr>; |
|
||||
| Test.kt:43:3:43:3 | <Expr>; | Test.kt:43:3:43:3 | z |
|
||||
| Test.kt:43:3:43:3 | z | Test.kt:43:8:43:8 | y |
|
||||
| Test.kt:43:3:43:15 | plus(...) | Test.kt:43:3:43:3 | ...=... |
|
||||
| Test.kt:43:8:43:8 | y | Test.kt:43:8:43:15 | (...)... |
|
||||
| Test.kt:43:8:43:15 | (...)... | Test.kt:43:3:43:15 | plus(...) |
|
||||
| Test.kt:73:3:73:3 | ...=... | Test.kt:77:3:77:3 | <Expr>; |
|
||||
| Test.kt:43:8:43:15 | (...)... | Test.kt:43:3:43:3 | ...+=... |
|
||||
| Test.kt:73:3:73:3 | ...+=... | Test.kt:77:3:77:3 | <Expr>; |
|
||||
| Test.kt:73:3:73:3 | <Expr>; | Test.kt:73:3:73:3 | z |
|
||||
| Test.kt:73:3:73:3 | z | Test.kt:73:8:73:8 | x |
|
||||
| Test.kt:73:3:73:16 | plus(...) | Test.kt:73:3:73:3 | ...=... |
|
||||
| Test.kt:73:8:73:8 | x | Test.kt:73:12:73:12 | y |
|
||||
| Test.kt:73:8:73:12 | ... + ... | Test.kt:73:16:73:16 | w |
|
||||
| Test.kt:73:8:73:16 | ... + ... | Test.kt:73:3:73:16 | plus(...) |
|
||||
| Test.kt:73:8:73:16 | ... + ... | Test.kt:73:3:73:3 | ...+=... |
|
||||
| Test.kt:73:12:73:12 | <implicit cast> | Test.kt:73:8:73:12 | ... + ... |
|
||||
| Test.kt:73:12:73:12 | y | Test.kt:73:12:73:12 | <implicit cast> |
|
||||
| Test.kt:73:16:73:16 | w | Test.kt:73:8:73:16 | ... + ... |
|
||||
|
||||
@@ -884,6 +884,31 @@ exprs.kt:
|
||||
# 257| 0: [MulExpr] ... * ...
|
||||
# 257| 0: [VarAccess] fx
|
||||
# 257| 1: [VarAccess] fy
|
||||
# 261| 11: [Method] inPlaceOperators
|
||||
# 261| 5: [BlockStmt] { ... }
|
||||
# 263| 0: [LocalVariableDeclStmt] var ...;
|
||||
# 263| 1: [LocalVariableDeclExpr] updated
|
||||
# 263| 0: [IntegerLiteral] 0
|
||||
# 264| 1: [ExprStmt] <Expr>;
|
||||
# 264| 0: [AssignAddExpr] ...+=...
|
||||
# 264| 0: [VarAccess] updated
|
||||
# 264| 1: [IntegerLiteral] 1
|
||||
# 265| 2: [ExprStmt] <Expr>;
|
||||
# 265| 0: [AssignSubExpr] ...-=...
|
||||
# 265| 0: [VarAccess] updated
|
||||
# 265| 1: [IntegerLiteral] 1
|
||||
# 266| 3: [ExprStmt] <Expr>;
|
||||
# 266| 0: [AssignMulExpr] ...*=...
|
||||
# 266| 0: [VarAccess] updated
|
||||
# 266| 1: [IntegerLiteral] 1
|
||||
# 267| 4: [ExprStmt] <Expr>;
|
||||
# 267| 0: [AssignDivExpr] .../=...
|
||||
# 267| 0: [VarAccess] updated
|
||||
# 267| 1: [IntegerLiteral] 1
|
||||
# 268| 5: [ExprStmt] <Expr>;
|
||||
# 268| 0: [AssignRemExpr] ...%=...
|
||||
# 268| 0: [VarAccess] updated
|
||||
# 268| 1: [IntegerLiteral] 1
|
||||
# 142| 2: [Class] C
|
||||
# 142| 1: [Constructor] C
|
||||
#-----| 4: (Parameters)
|
||||
|
||||
@@ -720,6 +720,23 @@
|
||||
| exprs.kt:257:11:257:12 | fx | exprs.kt:246:1:259:1 | mulOperators | VarAccess |
|
||||
| exprs.kt:257:11:257:17 | ... * ... | exprs.kt:246:1:259:1 | mulOperators | MulExpr |
|
||||
| exprs.kt:257:16:257:17 | fy | exprs.kt:246:1:259:1 | mulOperators | VarAccess |
|
||||
| exprs.kt:263:3:263:17 | updated | exprs.kt:261:1:270:1 | inPlaceOperators | LocalVariableDeclExpr |
|
||||
| exprs.kt:263:17:263:17 | 0 | exprs.kt:261:1:270:1 | inPlaceOperators | IntegerLiteral |
|
||||
| exprs.kt:264:3:264:9 | ...+=... | exprs.kt:261:1:270:1 | inPlaceOperators | AssignAddExpr |
|
||||
| exprs.kt:264:3:264:9 | updated | exprs.kt:261:1:270:1 | inPlaceOperators | VarAccess |
|
||||
| exprs.kt:264:14:264:14 | 1 | exprs.kt:261:1:270:1 | inPlaceOperators | IntegerLiteral |
|
||||
| exprs.kt:265:3:265:9 | ...-=... | exprs.kt:261:1:270:1 | inPlaceOperators | AssignSubExpr |
|
||||
| exprs.kt:265:3:265:9 | updated | exprs.kt:261:1:270:1 | inPlaceOperators | VarAccess |
|
||||
| exprs.kt:265:14:265:14 | 1 | exprs.kt:261:1:270:1 | inPlaceOperators | IntegerLiteral |
|
||||
| exprs.kt:266:3:266:9 | ...*=... | exprs.kt:261:1:270:1 | inPlaceOperators | AssignMulExpr |
|
||||
| exprs.kt:266:3:266:9 | updated | exprs.kt:261:1:270:1 | inPlaceOperators | VarAccess |
|
||||
| exprs.kt:266:14:266:14 | 1 | exprs.kt:261:1:270:1 | inPlaceOperators | IntegerLiteral |
|
||||
| exprs.kt:267:3:267:9 | .../=... | exprs.kt:261:1:270:1 | inPlaceOperators | AssignDivExpr |
|
||||
| exprs.kt:267:3:267:9 | updated | exprs.kt:261:1:270:1 | inPlaceOperators | VarAccess |
|
||||
| exprs.kt:267:14:267:14 | 1 | exprs.kt:261:1:270:1 | inPlaceOperators | IntegerLiteral |
|
||||
| exprs.kt:268:3:268:9 | ...%=... | exprs.kt:261:1:270:1 | inPlaceOperators | AssignRemExpr |
|
||||
| exprs.kt:268:3:268:9 | updated | exprs.kt:261:1:270:1 | inPlaceOperators | VarAccess |
|
||||
| exprs.kt:268:14:268:14 | 1 | exprs.kt:261:1:270:1 | inPlaceOperators | IntegerLiteral |
|
||||
| funcExprs.kt:16:5:16:33 | functionExpression0a(...) | funcExprs.kt:15:1:46:1 | call | MethodAccess |
|
||||
| funcExprs.kt:16:26:16:33 | ...->... | funcExprs.kt:15:1:46:1 | call | LambdaExpr |
|
||||
| funcExprs.kt:16:26:16:33 | Function0<Integer> | funcExprs.kt:15:1:46:1 | call | TypeAccess |
|
||||
|
||||
@@ -257,3 +257,14 @@ fun mulOperators(x: Int, y: Int,
|
||||
val f = fx * fy
|
||||
|
||||
}
|
||||
|
||||
fun inPlaceOperators() {
|
||||
|
||||
var updated = 0
|
||||
updated += 1
|
||||
updated -= 1
|
||||
updated *= 1
|
||||
updated /= 1
|
||||
updated %= 1
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user