[PATCH] D117759: [clang-format][NFC] Clean up tryMergeLessLess()

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 20 02:38:30 PST 2022


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

LGTM.



================
Comment at: clang/lib/Format/FormatTokenLexer.cpp:440-441
 
-  if (First[2]->is(tok::less) || First[1]->isNot(tok::less) ||
-      First[0]->isNot(tok::less) || FourthTokenIsLess)
+  if (Y->is(tok::less) || First[1]->isNot(tok::less) ||
+      First[0]->isNot(tok::less) || (X && X->is(tok::less)))
     return false;
----------------
To go a bit further, could we move `First[1]->isNot(tok::less) || First[0]->isNot(tok::less)` into its own `if` around the top of the function?
Sth like:
```
  if (Tokens.size() < 3)
    return false;

  auto First = Tokens.end() - 3;
  if (First[0]->isNot(tok::less) || First[1]->isNot(tok::less))
    return false;
```
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117759



More information about the cfe-commits mailing list