[PATCH] D118924: [clang-format] Fix formatting of macro definitions with a leading comment.

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 4 06:33:11 PST 2022


curdeius added a comment.

Indeed, I get the hash on the 2nd line merged into the first one in this test case:

  verifyFormat("/* comment */ #define A (parentheses)\n"
              "#");

But! It's unrelated to whether `PreviousWasComment` is updated inside the loop or not.
Actually it should not be important because `#` always starts a preprocessor macro and no other statement (at least in C and C++).
On the other hand, `FirstNonCommentOnLine` should be updated in the loop but I still don't have a test case for this (again, because there's no statement that starts with `#`).

Interestingly, the problem I encountered with the test case above doesn't happen when there's a new line after `#`:

  verifyFormat("/* comment */ #define A (parentheses)\n"
               "#\n");

Anyway, this merging happens due to something else, but I don't know yet what exactly.
Investigating...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118924



More information about the cfe-commits mailing list