This patch is the result of running clang-format -style="{InsertBraces: true, RemoveBracesLLVM: true}" (version 09865ae) on clang/lib/Format/.
Details
Diff Detail
Event Timeline
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
2769 | From https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements, it's unclear whether the braces should be removed when a block has a do-while loop as its single statement. Should I put the braces back and add handling of do-while for RemoveBracesLLVM? | |
clang/lib/Format/WhitespaceManager.cpp | ||
231–239 | It would be nice to remove the braces of the else here. See https://github.com/llvm/llvm-project/issues/55663. |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
2769 | It's indeed not clear, I remember having paused over this code for a moment. | |
clang/lib/Format/WhitespaceManager.cpp | ||
231–239 | +1. Would you fix it manually here then and fix it later? |
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
2769 | Good idea. I don't think there's any consensus specifically about this but will ask on discourse.llvm.org. To err on the conservative side, I will manually add the braces back for now. | |
clang/lib/Format/WhitespaceManager.cpp | ||
231–239 | I will leave it as is and use it as a test case for later. Implementing this would add more complexity to RemoveBracesLLVM, which is complex enough already. I will look into it in a few months as I will be away for the summer. |
From https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements, it's unclear whether the braces should be removed when a block has a do-while loop as its single statement. Should I put the braces back and add handling of do-while for RemoveBracesLLVM?