Fix spacing after binary operator as macro parameter.

Before: COMPARE(a, == , b);
After:  COMPARE(a, ==, b);
llvm-svn: 176241
This commit is contained in:
Daniel Jasper 2013-02-28 09:21:10 +00:00
parent 4c9300e630
commit d8ffcfa9b8
2 changed files with 6 additions and 1 deletions

View File

@ -1048,7 +1048,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
Tok.Parent->Type == TT_TemplateCloser &&
Style.Standard != FormatStyle::LS_Cpp11;
}
if (Tok.Type == TT_BinaryOperator || Tok.Parent->Type == TT_BinaryOperator)
if (Tok.Type == TT_BinaryOperator ||
(Tok.Parent->Type == TT_BinaryOperator && Tok.isNot(tok::comma)))
return true;
if (Tok.Parent->Type == TT_TemplateCloser && Tok.is(tok::l_paren))
return false;

View File

@ -1709,6 +1709,10 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
verifyFormat("template <typename T> void f() {}");
}
TEST_F(FormatTest, UnderstandsBinaryOperators) {
verifyFormat("COMPARE(a, ==, b);");
}
TEST_F(FormatTest, UnderstandsUnaryOperators) {
verifyFormat("int a = -2;");
verifyFormat("f(-1, -2, -3);");