aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/TokenAnnotator.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp4
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 164b722f82..6b91993c4f 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -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;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 5be319cba0..81833e5e02 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -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);");