[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

Nathan Hjelm via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 08:28:38 PDT 2021


hjelmn added inline comments.


================
Comment at: clang/docs/ReleaseNotes.rst:168
 
+- Option ``SpaceBeforeForLoopSemiColon`` has been added to control whether
+  spaces will be added before the semi-colons in for loops.
----------------
HazardyKnusperkeks wrote:
> No need for change, but in the future I would prefer to add changes to the end of the list. :)
Opps. Should have asked the convention before putting it at the top. I will go ahead and move it to be consistent with LLVM practice.


================
Comment at: clang/unittests/Format/FormatTest.cpp:12712
+  verifyFormat("for (i = 0 ; i < 10 ; ++i) {\n}", Space);
+  verifyFormat("for (int i = 0 ; auto a : b) {\n}", Space);
+}
----------------
HazardyKnusperkeks wrote:
> Okay that was unexpected for me, I thought the space would only apply to the old `for`s.
> 
> In that case please add `while` and maybe `if` with initializer. What should be discussed is if `for` and the other control statements with initializer should behave differently with regard to their initializer semicolon.
hmm, I think then I could rename this one to: SpaceBeforeCForLoopSemiColon which would then only add spaces in for(init;cond;increment)
then maybe SpaceAfterControlStatementInitializer or SpaceBeforeControlStatementSemiColon that controls the behavior for control statements with initializers.

How does that sound?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98429/new/

https://reviews.llvm.org/D98429



More information about the cfe-commits mailing list