!PrevToken->MatchingParen)
return TT_PointerOrReference;
+ if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete))
+ return TT_UnaryOperator;
+
if (PrevToken->Tok.isLiteral() ||
PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
tok::kw_false, tok::r_brace)) {
"} &&ptr = {};",
Style);
+ Style.PointerAlignment = FormatStyle::PAS_Left;
+ verifyFormat("delete[] *ptr;", Style);
+ verifyFormat("delete[] **ptr;", Style);
+ verifyFormat("delete[] *(ptr);", Style);
+
verifyIndependentOfContext("MACRO(int *i);");
verifyIndependentOfContext("MACRO(auto *a);");
verifyIndependentOfContext("MACRO(const A *a);");
Tokens = annotate("int i = int{42} * 2;");
EXPECT_EQ(Tokens.size(), 11u) << Tokens;
EXPECT_TOKEN(Tokens[7], tok::star, TT_BinaryOperator);
+
+ Tokens = annotate("delete[] *ptr;");
+ EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+ EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+ Tokens = annotate("delete[] **ptr;");
+ EXPECT_EQ(Tokens.size(), 8u) << Tokens;
+ EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
+ EXPECT_TOKEN(Tokens[4], tok::star, TT_UnaryOperator);
+ Tokens = annotate("delete[] *(ptr);");
+ EXPECT_EQ(Tokens.size(), 9u) << Tokens;
+ EXPECT_TOKEN(Tokens[3], tok::star, TT_UnaryOperator);
}
TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {