diff options
| author | Daniel Jasper <djasper@google.com> | 2013-02-28 09:21:10 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-02-28 09:21:10 +0000 |
| commit | d8ffcfa9b87c9d08022cc916d41044d2d18e2cfd (patch) | |
| tree | 54e17ff67a652e8ccf9f15e74ce4f737baf440a8 /clang | |
| parent | 4c9300e630145f6f0a6b622393d83bbe46e5c4f5 (diff) | |
| download | bcm5719-llvm-d8ffcfa9b87c9d08022cc916d41044d2d18e2cfd.tar.gz bcm5719-llvm-d8ffcfa9b87c9d08022cc916d41044d2d18e2cfd.zip | |
Fix spacing after binary operator as macro parameter.
Before: COMPARE(a, == , b);
After: COMPARE(a, ==, b);
llvm-svn: 176241
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 164b722f820..6b91993c4ff 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 5be319cba03..81833e5e02c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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);"); |

