[PATCH] D110833: [clang-format] Refactor SpaceBeforeParens to add flags

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 25 03:00:25 PDT 2021


HazardyKnusperkeks added inline comments.


================
Comment at: clang/include/clang/Format/Format.h:3422
   ///    true:                                  false:
-  ///    for (auto v : values) {}       vs.     for(auto v: values) {}
+  ///    for (auto v : values) {}       vs.     for (auto v: values) {}
   /// \endcode
----------------
crayroud wrote:
> HazardyKnusperkeks wrote:
> > Please remove again. :)
> I changed the documentation to have a space added or removed only before the for loop colon. Indeed the space after the for is handled by SpaceBeforeParens... and not SpaceBeforeRangeBasedForLoopColon. Why do you think it is better to keep it as before ?
I must admit, I did not notice that the space is for the colon not the paren.

But nevertheless this is an unrelated change. You are very welcome to fix it, in its own commit.


================
Comment at: clang/lib/Format/Format.cpp:1221
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
+  LLVMStyle.SpaceBeforeParensFlags.AfterControlStatements = true;
+  LLVMStyle.SpaceBeforeParensFlags.AfterOperators = true;
----------------
crayroud wrote:
> HazardyKnusperkeks wrote:
> > Is this needed? Shouldn't the expand take care of that?
> Indeed the expand takes care of that and it would be nice not to have to repeat it here.
> I had to add it for the test FormatTest.ConfigurationRoundTripTest, as it is done for LLVMStyle.BraceWrapping.
> What do you think is best ?
If that's the case, than it may be so.


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

https://reviews.llvm.org/D110833



More information about the cfe-commits mailing list