matt-kempster / m2c

A MIPS and PowerPC decompiler.
GNU General Public License v3.0
410 stars 49 forks source link

Move "end" switch labels to inside the switch block #236

Closed zbanks closed 2 years ago

zbanks commented 2 years ago

This moves case ...: labels that were previously immediately outside of the switch block to case ...: break; statements at the top of the switch.

This avoids syntax errors (and is easier to read). It fixes the issue that camthesaxman brought up on Discord about func_80048084.

This might not be the absolute cleanest way of implementing this: it's a bit odd to remove labels from case_nodes[...]. But it doesn't break --gotos-only where add_labels_for_switch(...) is used without build_switch_statement(...).

Diffs in PPC projects -- it's relatively small for 6 projects, and it all looks reasonable to me.