This repository was archived by the owner on Jan 5, 2023. It is now read-only.
Commit 4882f27
committed
Remove spurious control-flow edge around switch block without a test-expression
Previously we thought it possible to get from top to bottom of a block like "switch { case f(): ... }", when in fact this is only possible if there are no case blocks to execute.
I also add tests for two possible corner cases of a switch without a test-expression: a completely empty switch (the 'true' is indeed the last node) and switch with an empty default block (a single 'skip' is generated for the default block and the 'true' is not the last node)1 parent 1dc427a commit 4882f27
3 files changed
Lines changed: 24 additions & 6 deletions
File tree
- ql
- src/semmle/go/controlflow
- test/library-tests/semmle/go/controlflow/ControlFlowGraph
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1772 | 1772 | | |
1773 | 1773 | | |
1774 | 1774 | | |
1775 | | - | |
1776 | | - | |
1777 | | - | |
1778 | 1775 | | |
1779 | 1776 | | |
1780 | 1777 | | |
| |||
1783 | 1780 | | |
1784 | 1781 | | |
1785 | 1782 | | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
1786 | 1787 | | |
1787 | 1788 | | |
1788 | 1789 | | |
| |||
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1206 | 1206 | | |
1207 | 1207 | | |
1208 | 1208 | | |
1209 | | - | |
1210 | 1209 | | |
1211 | 1210 | | |
1212 | 1211 | | |
| |||
1232 | 1231 | | |
1233 | 1232 | | |
1234 | 1233 | | |
1235 | | - | |
| 1234 | + | |
1236 | 1235 | | |
1237 | 1236 | | |
1238 | 1237 | | |
1239 | 1238 | | |
1240 | | - | |
1241 | 1239 | | |
1242 | 1240 | | |
1243 | 1241 | | |
| |||
1254 | 1252 | | |
1255 | 1253 | | |
1256 | 1254 | | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments