[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 28 05:17:03 PST 2020


HazardyKnusperkeks added inline comments.


================
Comment at: clang/docs/ClangFormatStyleOptions.rst:2727
+
+  * ``unsigned Maximum`` The maximum number of spaces at the start of the comment.
+
----------------
MyDeveloperDay wrote:
> I'm personally not a massive fan of stuffing -1 into an unsigned but I understand why its there, if this was an signed and it was actually -1 would the algorithm be substantially worse in your view?
I'm no fan if unsigned in any way, but that seems to be the way in clang-format.
Making it signed would require a few more checks when to use it, but I don't see any problem in that.
I just would also make the Minimum signed then just to be consistent.

While parsing the style I would add checks to ensure Minimum is never negative and Maximum is always greater or equal to -1, should that print any warnings? Is there a standard way of doing so? Or should it be just silently corrected?


================
Comment at: clang/lib/Format/BreakableToken.cpp:797
+            IndentPrefix
+                .drop_back(SpacesInPrefix - Style.SpacesInLineComments.Maximum)
+                .str();
----------------
MyDeveloperDay wrote:
> my assumption is when Maximum is -1 this is a very large -ve number correct? is that defined behavior for drop_back()
Since we check beforehand SpacesInPrefix is larger than Maximum there is no problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257



More information about the cfe-commits mailing list