Formatter: + and - after { are unary operators.
authorNico Weber <nicolasweber@gmx.de>
Sat, 12 Jan 2013 05:41:23 +0000 (05:41 +0000)
committerNico Weber <nicolasweber@gmx.de>
Sat, 12 Jan 2013 05:41:23 +0000 (05:41 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172301 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/Format.cpp
unittests/Format/FormatTest.cpp

index 77fba1fbf1ca0111e67508e7633a1b5e3e956e03..5140639d009b60609a94a71704346f6393513d50 100644 (file)
@@ -994,7 +994,7 @@ private:
         Tok.Parent->is(tok::comma) || Tok.Parent->is(tok::l_square) ||
         Tok.Parent->is(tok::question) || Tok.Parent->is(tok::colon) ||
         Tok.Parent->is(tok::kw_return) || Tok.Parent->is(tok::kw_case) ||
-        Tok.Parent->is(tok::at))
+        Tok.Parent->is(tok::at) || Tok.Parent->is(tok::l_brace))
       return TT_UnaryOperator;
 
     // There can't be to consecutive binary operators.
index 061ac5710d629b208961a63df54ad04ebeccbf4c..9106a1fc7f3173af3918b76a737d1a177d966f84 100644 (file)
@@ -956,6 +956,9 @@ TEST_F(FormatTest, UnderstandsUnaryOperators) {
                "case -1:\n"
                "  break;\n"
                "}");
+
+  verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { -5, +3 };");
+  verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { +5, -3 };");
 }
 
 TEST_F(FormatTest, UndestandsOverloadedOperators) {