-
Format switch statements consistently · 112faf44Nicolas Capens authored
Each non-fallthrough case should end with a break (or return). If a scope is needed because local variables are defined, it should end before this break. This avoids bugs such as: switch(i) { case 0: if(c) { // lots // of // code // Easy to misread as always breaking instead of conditionally // falling through due to not spotting the if(c). break; } case 1: // ... } The new scope should also be indented. It makes it easier to spot where each case ends and where the switch ends. This is achieved by setting IndentCaseBlocks to true. Lastly, the case labels themselves should not be indented. Like goto labels they mark where in the code to jump to, and the code itself is already indented within the switch block. Bug: b/144825072 Change-Id: I9a130d1d234795f53b5872e411f1315f56a0e908 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39551 Commit-Queue: Nicolas Capens <nicolascapens@google.com> Tested-by:Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by:
Alexis Hétu <sugoi@google.com>
112faf44
×