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

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 16 12:36:07 PDT 2021


HazardyKnusperkeks added a subscriber: curdeius.
HazardyKnusperkeks 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.
----------------
hjelmn wrote:
> 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.
Don't know about LLVM practice, I'm just about 4 month here. Just my preference (and how I've done it until now).


================
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);
+}
----------------
hjelmn wrote:
> 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?
Apart from the names good. For the names I don't have anything really better right now.

But this is currently just my opinion, we should ask @MyDeveloperDay and @curdeius.


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