C#: Fix CFG for fall-through switch statements #19380
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks to @aschackmull for making me aware, and providing the example.
Before
flowchart TD 1["enter M16"] 10["2"] 11["call to method WriteLine"] 12["...;"] 13[""1 or 2""] 14["break;"] 15["case ...:"] 16["3"] 17["call to method WriteLine"] 18["...;"] 19[""3""] 2["exit M16"] 20["break;"] 21["default:"] 22["call to method WriteLine"] 23["...;"] 24[""def""] 25["break;"] 3["exit M16 (normal)"] 4["{...}"] 5["switch (...) {...}"] 6["access to parameter i"] 7["case ...:"] 8["1"] 9["case ...:"] 1 --> 4 3 --> 2 4 --> 5 5 --> 6 6 --> 7 7 --> 8 8 -- match, no-match --> 9 9 --> 10 10 -- match --> 12 10 -- no-match --> 14 10 -- no-match --> 15 11 --> 14 12 --> 13 13 --> 11 14 -- break --> 3 15 --> 16 16 -- match --> 18 16 -- no-match --> 21 17 --> 20 18 --> 19 19 --> 17 20 -- break --> 3 21 --> 23 22 --> 25 23 --> 24 24 --> 22 25 -- break --> 3After
flowchart TD 1["enter M16"] 10["2"] 11["call to method WriteLine"] 12["...;"] 13[""1 or 2""] 14["break;"] 15["case ...:"] 16["3"] 17["call to method WriteLine"] 18["...;"] 19[""3""] 2["exit M16"] 20["break;"] 21["default:"] 22["call to method WriteLine"] 23["...;"] 24[""def""] 25["break;"] 3["exit M16 (normal)"] 4["{...}"] 5["switch (...) {...}"] 6["access to parameter i"] 7["case ...:"] 8["1"] 9["case ...:"] 1 --> 4 3 --> 2 4 --> 5 5 --> 6 6 --> 7 7 --> 8 8 -- match --> 12 8 -- no-match --> 9 9 --> 10 10 -- match --> 12 10 -- no-match --> 15 11 --> 14 12 --> 13 13 --> 11 14 -- break --> 3 15 --> 16 16 -- match --> 18 16 -- no-match --> 21 17 --> 20 18 --> 19 19 --> 17 20 -- break --> 3 21 --> 23 22 --> 25 23 --> 24 24 --> 22 25 -- break --> 3