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>
| Name |
Last commit
|
Last update |
|---|---|---|
| .. | ||
| Context.cpp | Loading commit data... | |
| Context.hpp | Loading commit data... | |
| Debug.cpp | Loading commit data... | |
| EventListener.cpp | Loading commit data... | |
| EventListener.hpp | Loading commit data... | |
| File.cpp | Loading commit data... | |
| File.hpp | Loading commit data... | |
| ID.hpp | Loading commit data... | |
| Location.hpp | Loading commit data... | |
| Server.cpp | Loading commit data... | |
| Server.hpp | Loading commit data... | |
| Thread.cpp | Loading commit data... | |
| Thread.hpp | Loading commit data... | |
| TypeOf.cpp | Loading commit data... | |
| TypeOf.hpp | Loading commit data... | |
| Value.cpp | Loading commit data... | |
| Value.hpp | Loading commit data... | |
| Variable.cpp | Loading commit data... | |
| Variable.hpp | Loading commit data... | |
| WeakMap.hpp | Loading commit data... |