[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage
Björn Schäpers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 17 12:54:22 PDT 2022
HazardyKnusperkeks added inline comments.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2138
+
+ // These keywords are deliberately not included here. They are either
+ // included in determineStarAmpUsage or determinePlusMinusCaretUsage.
----------------
I'm not sure about this. Why not handle them here too?
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2146-2147
+ // know how they can be followed by a star or amp.
+ // co_await, delete - It doesn't make sense to have them followed by a unary
+ // `+` or `-`.
+ if (PrevToken->isOneOf(TT_ConditionalExpr, tok::l_paren, tok::comma,
----------------
Especially here, why should a `+` after `delete` be a binary operator?
How much sense it makes doesn't matter, it is valid c++: https://gcc.godbolt.org/z/c1x1nn3Ej
================
Comment at: clang/unittests/Format/FormatTest.cpp:9758
+ verifyFormat("for (x = 0; -10 < x; --x) {\n}");
+ verifyFormat("sizeof -x");
+ verifyFormat("sizeof +x");
----------------
A format test is fine, a token annotator test would be better.
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