[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 16 02:28:15 PDT 2022


curdeius requested changes to this revision.
curdeius added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2161
 
-    if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
-                           tok::comma, tok::semi, tok::kw_return, tok::colon,
-                           tok::kw_co_return, tok::kw_co_await,
-                           tok::kw_co_yield, tok::equal, tok::kw_delete,
-                           tok::kw_sizeof, tok::kw_throw, TT_BinaryOperator,
-                           TT_ConditionalExpr, TT_UnaryOperator, TT_CastRParen))
+    if (determinePlusMinusCaretUsage(Tok) == TT_UnaryOperator)
       return TT_UnaryOperator;
----------------
As below, before, question, kw_return, kw_case, at were not handled here.
Please add tests.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2208-2214
+    if (PrevToken->isOneOf(
+            TT_BinaryOperator, TT_CastRParen, TT_ConditionalExpr,
+            TT_UnaryOperator, tok::l_paren, tok::comma, tok::colon, tok::semi,
+            tok::equal, tok::question, tok::at, tok::l_square, tok::l_brace,
+            tok::kw_case, tok::kw_co_await, tok::kw_co_return, tok::kw_co_yield,
+            tok::kw_delete, tok::kw_return, tok::kw_sizeof, tok::kw_throw))
       return TT_UnaryOperator;
----------------
I don't like this part of your patch. You remove comments for no real gain.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2209-2213
+            TT_BinaryOperator, TT_CastRParen, TT_ConditionalExpr,
+            TT_UnaryOperator, tok::l_paren, tok::comma, tok::colon, tok::semi,
+            tok::equal, tok::question, tok::at, tok::l_square, tok::l_brace,
+            tok::kw_case, tok::kw_co_await, tok::kw_co_return, tok::kw_co_yield,
+            tok::kw_delete, tok::kw_return, tok::kw_sizeof, tok::kw_throw))
----------------
There were no TT_ConditionalExpr, semi, kw_co_await, kw_delete, kw_sizeof, kw_throw before.
I'd like to see tests for each of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121754



More information about the cfe-commits mailing list