Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1493,7 +1493,8 @@ return TT_UnaryOperator; if (PrevToken->isOneOf(TT_CastRParen, TT_UnaryOperator) && - !PrevToken->is(tok::exclaim)) + !(PrevToken->is(tok::exclaim) && + Style.Language == FormatStyle::LK_JavaScript)) // There aren't any trailing unary operators except for TypeScript's // non-null operator (!). Thus, this must be squence of leading operators. return TT_UnaryOperator; Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -5655,6 +5655,8 @@ verifyFormat("(a->f())++;"); verifyFormat("a[42]++;"); verifyFormat("if (!(a->f())) {\n}"); + verifyFormat("if (!+i) {\n}"); + verifyFormat("~&a;"); verifyFormat("a-- > b;"); verifyFormat("b ? -a : c;");