Commit 6f42153
committed
Ruby: Include empty StmtSequences in CFG
Empty StmtSequences appear, for example, in the `else` branch of `if`
statements like the following:
foo
if cond
bar
else
end
baz
Before this change, the CFG for this code would look like this:
foo
│
│
▼
cond
│
true │
▼
bar
│
│
▼
if
│
│
▼
baz
i.e. there is linear flow through the condition, the `then` branch, and
out of the if. This doesn't account for the possibility that the
condition is false and `bar` is not executed. After this change, the CFG
looks like this:
foo
│
│
▼
cond
│ │
true │ │ false
▼ │
bar │
│ │
│ │
▼ ▼
if
│
│
▼
baz
i.e. we correctly account for the `false` condition.1 parent 6adfea2 commit 6f42153
File tree
2 files changed
+26
-1
lines changed- ruby/ql
- lib/codeql/ruby/controlflow/internal
- test/library-tests/controlflow/graph
2 files changed
+26
-1
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
932 | 932 | | |
933 | 933 | | |
934 | 934 | | |
935 | | - | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
936 | 942 | | |
937 | 943 | | |
938 | 944 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3675 | 3675 | | |
3676 | 3676 | | |
3677 | 3677 | | |
| 3678 | + | |
3678 | 3679 | | |
3679 | 3680 | | |
3680 | 3681 | | |
| |||
3689 | 3690 | | |
3690 | 3691 | | |
3691 | 3692 | | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
3692 | 3696 | | |
3693 | 3697 | | |
3694 | 3698 | | |
| |||
4006 | 4010 | | |
4007 | 4011 | | |
4008 | 4012 | | |
| 4013 | + | |
4009 | 4014 | | |
4010 | 4015 | | |
4011 | 4016 | | |
| |||
4014 | 4019 | | |
4015 | 4020 | | |
4016 | 4021 | | |
| 4022 | + | |
| 4023 | + | |
| 4024 | + | |
4017 | 4025 | | |
4018 | 4026 | | |
4019 | 4027 | | |
| |||
5116 | 5124 | | |
5117 | 5125 | | |
5118 | 5126 | | |
| 5127 | + | |
| 5128 | + | |
| 5129 | + | |
5119 | 5130 | | |
5120 | 5131 | | |
5121 | 5132 | | |
| 5133 | + | |
| 5134 | + | |
| 5135 | + | |
| 5136 | + | |
| 5137 | + | |
| 5138 | + | |
| 5139 | + | |
| 5140 | + | |
5122 | 5141 | | |
5123 | 5142 | | |
5124 | 5143 | | |
| |||
0 commit comments