[PATCH] D43312: [clang-format] fix handling of consecutive unary operators
Kevin Lee via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 15 14:30:15 PST 2018
kevinl added inline comments.
================
Comment at: lib/Format/TokenAnnotator.cpp:1497
+ !(PrevToken->is(tok::exclaim) &&
+ Style.Language == FormatStyle::LK_JavaScript))
// There aren't any trailing unary operators except for TypeScript's
----------------
krasimir wrote:
> I think that TypeScript has both `if (!cond)` and `x!`. I'd expect that `if (!+i) {\n}` is also handled in the TypeScript case. Could you add a test for this for TypeScript please.
Turns out the comment below was misleading. The `x!` operator is classified as `TT_JsNonNullAssertion` and not `TT_UnaryOperator`, so removing the check for `tok::exclaim` entirely fixes `if (!+i) {\n}` in TypeScript as well as C++. Tests are now added for both languages
Repository:
rC Clang
https://reviews.llvm.org/D43312
More information about the cfe-commits
mailing list