[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 22 06:39:40 PDT 2022


curdeius added a comment.

In D121451#3395801 <https://reviews.llvm.org/D121451#3395801>, @krasimir wrote:

> This makes me think that we should really consider not adding indent if the first character is punctuation WAI, with rationale:

That was the case before this patch.

> - comments starting with such characters often have special meaning, clang-format errors out on the conservative side to not touch them. Example is stuff like `//!` in Doxygen blocks: https://www.doxygen.nl/manual/docblocks.html (although that's special-handled elsewhere).

I'm aware of these special characters, but I wasn't aware of the fact that `#` is a special case too (I don't know proto too much).

> - it's possible to work around this by changing the source code to use `// #`; clang-format will respect indentation in that case (also for other punctuation characters).

Again, that was the case before this patch.

What I wanted to achieve was to only treat a limited list of special punctuation characters, not all of them.
As you mentioned, we have at least `///, //<, //!` for Doxygen comments. There are more of course.
I think that every (group of) language(s) should have a different way of defining whether a given character is special and so should be kept with the leading `//`.
I hope it makes sense given that C-language family is pretty different from Proto where it comes to comments.
So I'd rather keep the old behaviour for `#` in Proto but not in C-like languages.
Is that acceptable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121451



More information about the cfe-commits mailing list