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

Skip to content

Commit a427586

Browse files
tamasvajkigfoo
authored andcommitted
Fix location of variable access in LHS of assignment
1 parent 40e4c93 commit a427586

4 files changed

Lines changed: 23 additions & 9 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ open class KotlinFileExtractor(
14781478
tw.writeStatementEnclosingExpr(id, exprParent.enclosingStmt)
14791479

14801480
val lhsId = tw.getFreshIdLabel<DbVaraccess>()
1481-
tw.writeHasLocation(id, locId)
1481+
tw.writeHasLocation(lhsId, locId)
14821482
tw.writeCallableEnclosingExpr(lhsId, callable)
14831483

14841484
when (e) {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,20 @@
4040
| Test.kt:11:14:14:3 | { ... } | BlockStmt | Test.kt:12:4:12:4 | <Expr>; | ExprStmt |
4141
| Test.kt:12:4:12:4 | ...=... | AssignExpr | Test.kt:13:4:13:4 | <Expr>; | ExprStmt |
4242
| Test.kt:12:4:12:4 | <Expr>; | ExprStmt | Test.kt:12:8:12:9 | 20 | LongLiteral |
43+
| Test.kt:12:4:12:4 | y | VarAccess | file://:0:0:0:0 | <none> | <none> |
4344
| Test.kt:12:8:12:9 | 20 | LongLiteral | Test.kt:12:4:12:4 | ...=... | AssignExpr |
4445
| Test.kt:13:4:13:4 | ...=... | AssignExpr | Test.kt:18:3:18:3 | <Expr>; | ExprStmt |
4546
| Test.kt:13:4:13:4 | <Expr>; | ExprStmt | Test.kt:13:8:13:9 | 10 | IntegerLiteral |
47+
| Test.kt:13:4:13:4 | z | VarAccess | file://:0:0:0:0 | <none> | <none> |
4648
| Test.kt:13:8:13:9 | 10 | IntegerLiteral | Test.kt:13:4:13:4 | ...=... | AssignExpr |
4749
| Test.kt:14:10:16:3 | { ... } | BlockStmt | Test.kt:15:4:15:4 | <Expr>; | ExprStmt |
4850
| Test.kt:15:4:15:4 | ...=... | AssignExpr | Test.kt:18:3:18:3 | <Expr>; | ExprStmt |
4951
| Test.kt:15:4:15:4 | <Expr>; | ExprStmt | Test.kt:15:8:15:9 | 30 | LongLiteral |
52+
| Test.kt:15:4:15:4 | y | VarAccess | file://:0:0:0:0 | <none> | <none> |
5053
| Test.kt:15:8:15:9 | 30 | LongLiteral | Test.kt:15:4:15:4 | ...=... | AssignExpr |
5154
| Test.kt:18:3:18:3 | ...=... | AssignExpr | Test.kt:21:3:24:9 | <Expr>; | ExprStmt |
5255
| Test.kt:18:3:18:3 | <Expr>; | ExprStmt | Test.kt:18:7:18:7 | 0 | IntegerLiteral |
56+
| Test.kt:18:3:18:3 | z | VarAccess | file://:0:0:0:0 | <none> | <none> |
5357
| Test.kt:18:7:18:7 | 0 | IntegerLiteral | Test.kt:18:3:18:3 | ...=... | AssignExpr |
5458
| Test.kt:21:3:24:9 | ... -> ... | WhenBranch | Test.kt:21:3:24:9 | true | BooleanLiteral |
5559
| Test.kt:21:3:24:9 | ... -> ... | WhenBranch | Test.kt:21:6:21:6 | x | VarAccess |
@@ -61,11 +65,13 @@
6165
| Test.kt:21:10:21:10 | 0 | IntegerLiteral | Test.kt:21:6:21:10 | ... < ... | LTExpr |
6266
| Test.kt:22:4:22:4 | ...=... | AssignExpr | Test.kt:27:3:27:3 | <Expr>; | ExprStmt |
6367
| Test.kt:22:4:22:4 | <Expr>; | ExprStmt | Test.kt:22:8:22:9 | 40 | LongLiteral |
68+
| Test.kt:22:4:22:4 | y | VarAccess | file://:0:0:0:0 | <none> | <none> |
6469
| Test.kt:22:8:22:9 | 40 | LongLiteral | Test.kt:22:4:22:4 | ...=... | AssignExpr |
6570
| Test.kt:24:4:24:9 | INSTANCE | VarAccess | Test.kt:24:4:24:9 | return ... | ReturnStmt |
6671
| Test.kt:24:4:24:9 | return ... | ReturnStmt | file://:0:0:0:0 | <none> | <none> |
6772
| Test.kt:27:3:27:3 | ...=... | AssignExpr | Test.kt:30:3:33:3 | <Expr>; | ExprStmt |
6873
| Test.kt:27:3:27:3 | <Expr>; | ExprStmt | Test.kt:27:7:27:8 | 10 | IntegerLiteral |
74+
| Test.kt:27:3:27:3 | z | VarAccess | file://:0:0:0:0 | <none> | <none> |
6975
| Test.kt:27:7:27:8 | 10 | IntegerLiteral | Test.kt:27:3:27:3 | ...=... | AssignExpr |
7076
| Test.kt:30:3:33:3 | ... -> ... | WhenBranch | Test.kt:30:7:30:7 | x | VarAccess |
7177
| Test.kt:30:3:33:3 | <Expr>; | ExprStmt | Test.kt:30:3:33:3 | when ... | WhenExpr |
@@ -77,12 +83,15 @@
7783
| Test.kt:30:15:33:3 | { ... } | BlockStmt | Test.kt:31:4:31:4 | <Expr>; | ExprStmt |
7884
| Test.kt:31:4:31:4 | ...=... | AssignExpr | Test.kt:32:4:32:4 | <Expr>; | ExprStmt |
7985
| Test.kt:31:4:31:4 | <Expr>; | ExprStmt | Test.kt:31:8:31:9 | 60 | LongLiteral |
86+
| Test.kt:31:4:31:4 | y | VarAccess | file://:0:0:0:0 | <none> | <none> |
8087
| Test.kt:31:8:31:9 | 60 | LongLiteral | Test.kt:31:4:31:4 | ...=... | AssignExpr |
8188
| Test.kt:32:4:32:4 | ...=... | AssignExpr | Test.kt:35:3:35:3 | <Expr>; | ExprStmt |
8289
| Test.kt:32:4:32:4 | <Expr>; | ExprStmt | Test.kt:32:8:32:9 | 10 | IntegerLiteral |
90+
| Test.kt:32:4:32:4 | z | VarAccess | file://:0:0:0:0 | <none> | <none> |
8391
| Test.kt:32:8:32:9 | 10 | IntegerLiteral | Test.kt:32:4:32:4 | ...=... | AssignExpr |
8492
| Test.kt:35:3:35:3 | ...=... | AssignExpr | Test.kt:38:3:41:3 | while (...) | WhileStmt |
8593
| Test.kt:35:3:35:3 | <Expr>; | ExprStmt | Test.kt:35:7:35:8 | 20 | IntegerLiteral |
94+
| Test.kt:35:3:35:3 | z | VarAccess | file://:0:0:0:0 | <none> | <none> |
8695
| Test.kt:35:7:35:8 | 20 | IntegerLiteral | Test.kt:35:3:35:3 | ...=... | AssignExpr |
8796
| Test.kt:38:3:41:3 | while (...) | WhileStmt | Test.kt:38:9:38:9 | x | VarAccess |
8897
| Test.kt:38:9:38:9 | x | VarAccess | Test.kt:38:13:38:13 | 0 | IntegerLiteral |
@@ -92,9 +101,11 @@
92101
| Test.kt:38:16:41:3 | { ... } | BlockStmt | Test.kt:39:4:39:4 | <Expr>; | ExprStmt |
93102
| Test.kt:39:4:39:4 | ...=... | AssignExpr | Test.kt:40:4:40:6 | <Expr>; | ExprStmt |
94103
| Test.kt:39:4:39:4 | <Expr>; | ExprStmt | Test.kt:39:8:39:9 | 10 | LongLiteral |
104+
| Test.kt:39:4:39:4 | y | VarAccess | file://:0:0:0:0 | <none> | <none> |
95105
| Test.kt:39:8:39:9 | 10 | LongLiteral | Test.kt:39:4:39:4 | ...=... | AssignExpr |
96106
| Test.kt:40:4:40:4 | ...=... | AssignExpr | Test.kt:40:4:40:6 | <Expr>; | ExprStmt |
97107
| Test.kt:40:4:40:4 | <Expr>; | ExprStmt | Test.kt:40:4:40:6 | tmp0 | VarAccess |
108+
| Test.kt:40:4:40:4 | x | VarAccess | file://:0:0:0:0 | <none> | <none> |
98109
| Test.kt:40:4:40:4 | x | VarAccess | file://:0:0:0:0 | tmp0 | LocalVariableDeclExpr |
99110
| Test.kt:40:4:40:6 | (...)... | CastExpr | Test.kt:38:9:38:9 | x | VarAccess |
100111
| Test.kt:40:4:40:6 | <Expr>; | ExprStmt | Test.kt:40:4:40:6 | <Stmt> | StmtExpr |
@@ -107,12 +118,15 @@
107118
| Test.kt:40:4:40:6 | { ... } | BlockStmt | file://:0:0:0:0 | var ...; | LocalVariableDeclStmt |
108119
| Test.kt:43:3:43:3 | ...=... | AssignExpr | Test.kt:73:3:73:3 | <Expr>; | ExprStmt |
109120
| Test.kt:43:3:43:3 | <Expr>; | ExprStmt | Test.kt:43:7:43:8 | 30 | IntegerLiteral |
121+
| Test.kt:43:3:43:3 | z | VarAccess | file://:0:0:0:0 | <none> | <none> |
110122
| Test.kt:43:7:43:8 | 30 | IntegerLiteral | Test.kt:43:3:43:3 | ...=... | AssignExpr |
111123
| Test.kt:73:3:73:3 | ...=... | AssignExpr | Test.kt:77:3:77:3 | <Expr>; | ExprStmt |
112124
| Test.kt:73:3:73:3 | <Expr>; | ExprStmt | Test.kt:73:7:73:8 | 50 | IntegerLiteral |
125+
| Test.kt:73:3:73:3 | z | VarAccess | file://:0:0:0:0 | <none> | <none> |
113126
| Test.kt:73:7:73:8 | 50 | IntegerLiteral | Test.kt:73:3:73:3 | ...=... | AssignExpr |
114127
| Test.kt:77:3:77:3 | ...=... | AssignExpr | Test.kt:78:3:78:8 | INSTANCE | VarAccess |
115128
| Test.kt:77:3:77:3 | <Expr>; | ExprStmt | Test.kt:77:7:77:8 | 40 | IntegerLiteral |
129+
| Test.kt:77:3:77:3 | w | VarAccess | file://:0:0:0:0 | <none> | <none> |
116130
| Test.kt:77:7:77:8 | 40 | IntegerLiteral | Test.kt:77:3:77:3 | ...=... | AssignExpr |
117131
| Test.kt:78:3:78:8 | INSTANCE | VarAccess | Test.kt:78:3:78:8 | return ... | ReturnStmt |
118132
| Test.kt:78:3:78:8 | return ... | ReturnStmt | Test.kt:4:2:79:2 | test | Method |

java/ql/test/kotlin/library-tests/exprs/exprs.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@
461461
| exprs.kt:131:23:131:23 | 0 | exprs.kt:4:1:136:1 | topLevelMethod | IntegerLiteral |
462462
| exprs.kt:132:9:132:16 | ...=... | exprs.kt:4:1:136:1 | topLevelMethod | AssignExpr |
463463
| exprs.kt:132:9:132:16 | variable | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
464+
| exprs.kt:132:9:132:16 | variable | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |
464465
| exprs.kt:132:9:132:18 | (...)... | exprs.kt:4:1:136:1 | topLevelMethod | CastExpr |
465466
| exprs.kt:132:9:132:18 | <Stmt> | exprs.kt:4:1:136:1 | topLevelMethod | StmtExpr |
466467
| exprs.kt:132:9:132:18 | Unit | exprs.kt:4:1:136:1 | topLevelMethod | TypeAccess |
@@ -510,8 +511,10 @@
510511
| exprs.kt:156:9:156:22 | ...instanceof... | exprs.kt:150:1:157:1 | typeTests | InstanceOfExpr |
511512
| exprs.kt:156:9:156:22 | Subclass1 | exprs.kt:150:1:157:1 | typeTests | TypeAccess |
512513
| exprs.kt:156:27:156:27 | ...=... | exprs.kt:150:1:157:1 | typeTests | AssignExpr |
514+
| exprs.kt:156:27:156:27 | q | exprs.kt:150:1:157:1 | typeTests | VarAccess |
513515
| exprs.kt:156:31:156:31 | 2 | exprs.kt:150:1:157:1 | typeTests | IntegerLiteral |
514516
| exprs.kt:156:42:156:42 | ...=... | exprs.kt:150:1:157:1 | typeTests | AssignExpr |
517+
| exprs.kt:156:42:156:42 | q | exprs.kt:150:1:157:1 | typeTests | VarAccess |
515518
| exprs.kt:156:46:156:46 | 3 | exprs.kt:150:1:157:1 | typeTests | IntegerLiteral |
516519
| exprs.kt:160:5:160:25 | r | exprs.kt:159:1:166:1 | foo | LocalVariableDeclExpr |
517520
| exprs.kt:160:13:160:13 | p | exprs.kt:159:1:166:1 | foo | VarAccess |
@@ -527,6 +530,7 @@
527530
| exprs.kt:163:9:163:30 | height | exprs.kt:159:1:166:1 | foo | LocalVariableDeclExpr |
528531
| exprs.kt:163:25:163:30 | height | exprs.kt:159:1:166:1 | foo | VarAccess |
529532
| exprs.kt:164:9:164:17 | ...=... | exprs.kt:159:1:166:1 | foo | AssignExpr |
533+
| exprs.kt:164:9:164:17 | height | exprs.kt:159:1:166:1 | foo | VarAccess |
530534
| exprs.kt:164:21:164:21 | 3 | exprs.kt:159:1:166:1 | foo | IntegerLiteral |
531535
| exprs.kt:168:1:170:1 | <obinit>(...) | exprs.kt:168:6:170:1 | Direction | MethodAccess |
532536
| exprs.kt:168:1:170:1 | new Enum(...) | exprs.kt:168:6:170:1 | Direction | ClassInstanceExpr |
@@ -600,8 +604,4 @@
600604
| file://:0:0:0:0 | Interface1 | exprs.kt:187:13:192:5 | getObject | TypeAccess |
601605
| file://:0:0:0:0 | Unit | exprs.kt:168:6:170:1 | Direction | TypeAccess |
602606
| file://:0:0:0:0 | Unit | exprs.kt:172:6:176:1 | Color | TypeAccess |
603-
| file://:0:0:0:0 | height | exprs.kt:159:1:166:1 | foo | VarAccess |
604-
| file://:0:0:0:0 | q | exprs.kt:150:1:157:1 | typeTests | VarAccess |
605-
| file://:0:0:0:0 | q | exprs.kt:150:1:157:1 | typeTests | VarAccess |
606607
| file://:0:0:0:0 | tmp0 | exprs.kt:4:1:136:1 | topLevelMethod | LocalVariableDeclExpr |
607-
| file://:0:0:0:0 | variable | exprs.kt:4:1:136:1 | topLevelMethod | VarAccess |

java/ql/test/kotlin/library-tests/stmts/exprs.expected

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
| file://:0:0:0:0 | Exception | TypeAccess |
2-
| file://:0:0:0:0 | z | VarAccess |
3-
| file://:0:0:0:0 | z | VarAccess |
4-
| file://:0:0:0:0 | z | VarAccess |
5-
| file://:0:0:0:0 | z | VarAccess |
62
| stmts.kt:3:5:6:5 | when ... | WhenExpr |
73
| stmts.kt:3:8:3:8 | x | VarAccess |
84
| stmts.kt:3:8:3:12 | ... > ... | GTExpr |
@@ -30,16 +26,20 @@
3026
| stmts.kt:17:26:17:58 | when ... | WhenExpr |
3127
| stmts.kt:17:29:17:32 | true | BooleanLiteral |
3228
| stmts.kt:17:37:17:37 | ...=... | AssignExpr |
29+
| stmts.kt:17:37:17:37 | z | VarAccess |
3330
| stmts.kt:17:41:17:41 | 4 | IntegerLiteral |
3431
| stmts.kt:17:52:17:52 | ...=... | AssignExpr |
32+
| stmts.kt:17:52:17:52 | z | VarAccess |
3533
| stmts.kt:17:56:17:56 | 5 | IntegerLiteral |
3634
| stmts.kt:18:5:18:56 | q3 | LocalVariableDeclExpr |
3735
| stmts.kt:18:26:18:56 | true | BooleanLiteral |
3836
| stmts.kt:18:26:18:56 | when ... | WhenExpr |
3937
| stmts.kt:18:29:18:32 | true | BooleanLiteral |
4038
| stmts.kt:18:37:18:37 | ...=... | AssignExpr |
39+
| stmts.kt:18:37:18:37 | z | VarAccess |
4140
| stmts.kt:18:41:18:41 | 4 | IntegerLiteral |
4241
| stmts.kt:18:52:18:52 | ...=... | AssignExpr |
42+
| stmts.kt:18:52:18:52 | z | VarAccess |
4343
| stmts.kt:18:56:18:56 | 5 | IntegerLiteral |
4444
| stmts.kt:19:12:19:12 | x | VarAccess |
4545
| stmts.kt:19:12:19:16 | ... + ... | AddExpr |

0 commit comments

Comments
 (0)