Commit 22d3010
committed
Go CFG: fold compound-assign write into the compound-rhs instruction
A compound assignment (`x += y`) previously produced two sequential
control-flow nodes: a 'compound-rhs' node computing the binary operation
`x + y`, followed by an 'assign:0' write node storing the result.
Make the compound-rhs instruction itself perform the write (it becomes a
WriteInstruction whose right-hand side is its own value), and stop
emitting the separate assign:0 node for compound assignments. This saves
one CFG node per compound assignment while preserving the BinaryOperationNode
model (so string-concatenation taint through `s += ...` still holds) and
SSA semantics (the def value is the binary operation).1 parent 672260e commit 22d3010
4 files changed
Lines changed: 24 additions & 14 deletions
File tree
- go/ql
- lib/semmle/go/controlflow
- test/library-tests/semmle/go
- controlflow/ControlFlowGraph
- dataflow/SSA
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
505 | 510 | | |
506 | 511 | | |
507 | 512 | | |
| |||
1139 | 1144 | | |
1140 | 1145 | | |
1141 | 1146 | | |
1142 | | - | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
1143 | 1151 | | |
1144 | 1152 | | |
1145 | 1153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
736 | | - | |
737 | | - | |
738 | 736 | | |
739 | 737 | | |
740 | 738 | | |
741 | 739 | | |
742 | 740 | | |
743 | 741 | | |
744 | 742 | | |
745 | | - | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
746 | 746 | | |
747 | | - | |
| 747 | + | |
748 | 748 | | |
749 | 749 | | |
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | 754 | | |
| 755 | + | |
| 756 | + | |
755 | 757 | | |
756 | 758 | | |
757 | 759 | | |
| |||
1235 | 1237 | | |
1236 | 1238 | | |
1237 | 1239 | | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
1238 | 1244 | | |
1239 | 1245 | | |
1240 | 1246 | | |
| |||
Lines changed: 4 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1377 | 1377 | | |
1378 | 1378 | | |
1379 | 1379 | | |
1380 | | - | |
1381 | | - | |
| 1380 | + | |
1382 | 1381 | | |
1383 | 1382 | | |
1384 | 1383 | | |
| |||
2015 | 2014 | | |
2016 | 2015 | | |
2017 | 2016 | | |
2018 | | - | |
2019 | | - | |
| 2017 | + | |
2020 | 2018 | | |
2021 | 2019 | | |
2022 | 2020 | | |
| |||
2133 | 2131 | | |
2134 | 2132 | | |
2135 | 2133 | | |
2136 | | - | |
2137 | | - | |
| 2134 | + | |
2138 | 2135 | | |
2139 | 2136 | | |
2140 | 2137 | | |
| |||
2968 | 2965 | | |
2969 | 2966 | | |
2970 | 2967 | | |
2971 | | - | |
2972 | | - | |
| 2968 | + | |
2973 | 2969 | | |
2974 | 2970 | | |
2975 | 2971 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments