[PATCH] D117398: [clang-format] Fix bug in parsing `operator<` with template

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 18 00:33:21 PST 2022

curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

Thanks for working on this!

Do you have commit rights or do you need that someone lands it for you?
If you need help, please indicate your name and email to be used for the commit.

Also, if you think contributing more patches, have a look at https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access.

Comment at: clang/lib/Format/FormatTokenLexer.cpp:433-446
   bool FourthTokenIsLess = false;
-  if (Tokens.size() > 3)
-    FourthTokenIsLess = (Tokens.end() - 4)[0]->is(tok::less);
-  auto First = Tokens.end() - 3;
+  if (Tokens.size() > 3) {
+    auto Fourth = (Tokens.end() - 4)[0];
+    FourthTokenIsLess = Fourth->is(tok::less);
+    // Do not remove a whitespace between the two "<" e.g. "operator< <>".
I hate the naming here.
Unless I'm mistaken we have: Fourth, First + 0, First + 1, First + 2.
But I'll clean it up at some time.



More information about the cfe-commits mailing list