From eee7b81a168cc3f2a82882375109b9a059dde705 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sat, 12 Jan 2013 05:50:48 +0000 Subject: [PATCH] Formatter: * and & are binary operators before ( and [. llvm-svn: 172303 --- clang/lib/Format/Format.cpp | 1 + clang/unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index e4dc29131262..aa534b9ef3fa 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -974,6 +974,7 @@ private: NextToken.Tok.is(tok::plus) || NextToken.Tok.is(tok::minus) || NextToken.Tok.is(tok::plusplus) || NextToken.Tok.is(tok::minusminus) || NextToken.Tok.is(tok::tilde) || NextToken.Tok.is(tok::exclaim) || + NextToken.Tok.is(tok::l_paren) || NextToken.Tok.is(tok::l_square) || NextToken.Tok.is(tok::kw_alignof) || NextToken.Tok.is(tok::kw_sizeof)) return TT_BinaryOperator; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e5dbd630202b..4b3297db3df6 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1016,6 +1016,9 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("a * --b;"); verifyFormat("a[4] * b;"); verifyFormat("f() * b;"); + verifyFormat("a * [self dostuff];"); + verifyFormat("a * (a + b);"); + verifyFormat("(a *)(a + b);"); verifyFormat("int *pa = (int *)&a;"); verifyFormat("InvalidRegions[*R] = 0;");