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

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 30 02:59:16 PST 2020


MyDeveloperDay added a comment.

I think fundamentally from my perspective this seem ok, out of interest can I ask what drove you to require it?

My assumption is that some people write comments like

  // Free comment without space\n"

and you want to be able to consistently format it to be (N spaces, as clang-format already does 1 space correct?)

  //  Free comment without space\n"

is that correct? is there a common style guide asking for that? what is the rationale



================
Comment at: clang/lib/Format/BreakableToken.cpp:790
+          (Style.Language != FormatStyle::LK_TextProto ||
+           OriginalPrefix[i].substr(0, 2) != "##")) {
+        Prefix[i] = IndentPrefix.str();
----------------
is this case covered by a unit test at all? sorry can you explain why you are looking for "##"?


================
Comment at: clang/lib/Format/BreakableToken.cpp:797
+            IndentPrefix
+                .drop_back(SpacesInPrefix - Style.SpacesInLineComments.Maximum)
+                .str();
----------------
HazardyKnusperkeks wrote:
> 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.
yep sorry didn't see that.


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