Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/unittests/Format/FormatTest.cpp | ||
---|---|---|
25570–25575 | Why isn't this block changed like this? |
clang/unittests/Format/FormatTest.cpp | ||
---|---|---|
25570–25575 | It would cause a dangling else error because the last else would be paired with the inner merged else if. |
LGTM. Thanks!
clang/unittests/Format/FormatTest.cpp | ||
---|---|---|
25570–25575 | True. There are indeed no braces in the outer if. |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
2633 | To be precise. It doesn't matter now but will when we configure removing braces for other styles. |
Still looks good. Was there a particular case where the previous version didn't work?
The assertion I added on line 2626, which would ensure that the RemoveBraces lambda on line 898 didn't miss any potentially removable braces, would fail because parseLevel() was indiscriminately passing the l_brace of the last if in the level to its caller. This new version is also a tiny bit more efficient because IfLBrace on line 2624 will be null if the else block that encloses the if block is not a simple block.
Because neither version would remove non-optional braces, I decided not to add a test case just for the assertion, e.g.,
if (a) b; else { c; if (d) { e; f; } }
To be precise. It doesn't matter now but will when we configure removing braces for other styles.