[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
Mon Nov 30 12:30:29 PST 2020


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/BreakableToken.cpp:790
+          (Style.Language != FormatStyle::LK_TextProto ||
+           OriginalPrefix[i].substr(0, 2) != "##")) {
+        Prefix[i] = IndentPrefix.str();
----------------
HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > is this case covered by a unit test at all? sorry can you explain why you are looking for "##"?
> It is covered by multiple tests, that's how I was made aware of it. :)
> If you look at the code before it only adds a space if the old prefix is "#" not "##" which is also found by `getLineCommentIndentPrefix`. As it seems in `TextProto` "##" should not be touched. I can of course add a test in my test function.
> 
> Now I see a change, in the code before "#" was only accepted when the language is `TextProto`, now it is always. But I think for that to happen the parser (or lexer?) should have assigned something starting with"#" as comment, right? But I can change that.
Okay # # is formatted, I try again:
If you look at the code before it only adds a space if the old prefix is "#" not "`##`" which is also found by `getLineCommentIndentPrefix`. As it seems in `TextProto` "`##`" should not be touched.


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