This fixes llvm.org/PR14746.
Before: return - 1;
After: return -1;
llvm-svn: 171389
const Token &PreviousTok = Line.Tokens[Index - 1].Tok;
if (PreviousTok.is(tok::equal) || PreviousTok.is(tok::l_paren) ||
PreviousTok.is(tok::comma) || PreviousTok.is(tok::l_square) ||
- PreviousTok.is(tok::question) || PreviousTok.is(tok::colon))
+ PreviousTok.is(tok::question) || PreviousTok.is(tok::colon) ||
+ PreviousTok.is(tok::kw_return) || PreviousTok.is(tok::kw_case))
return TokenAnnotation::TT_UnaryOperator;
// There can't be to consecutive binary operators.
verifyFormat("b ? -a : c;");
verifyFormat("n * sizeof char16;");
verifyFormat("sizeof(char);");
+
+ verifyFormat("return -1;");
+ verifyFormat("switch (a) {\n"
+ "case -1:\n"
+ " break;\n"
+ "}");
}
TEST_F(FormatTest, UndestandsOverloadedOperators) {