r176241 - Fix spacing after binary operator as macro parameter.
Daniel Jasper
djasper at google.com
Thu Feb 28 01:21:11 PST 2013
Author: djasper
Date: Thu Feb 28 03:21:10 2013
New Revision: 176241
URL: http://llvm.org/viewvc/llvm-project?rev=176241&view=rev
Log:
Fix spacing after binary operator as macro parameter.
Before: COMPARE(a, == , b);
After: COMPARE(a, ==, b);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=176241&r1=176240&r2=176241&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu Feb 28 03:21:10 2013
@@ -1048,7 +1048,8 @@ bool TokenAnnotator::spaceRequiredBefore
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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=176241&r1=176240&r2=176241&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Feb 28 03:21:10 2013
@@ -1709,6 +1709,10 @@ TEST_F(FormatTest, UnderstandsTemplatePa
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);");
More information about the cfe-commits
mailing list