[cfe-commits] r172301 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp

Nico Weber nicolasweber at gmx.de
Fri Jan 11 21:41:24 PST 2013


Author: nico
Date: Fri Jan 11 23:41:23 2013
New Revision: 172301

URL: http://llvm.org/viewvc/llvm-project?rev=172301&view=rev
Log:
Formatter: + and - after { are unary operators.

Modified:
    cfe/trunk/lib/Format/Format.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172301&r1=172300&r2=172301&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Jan 11 23:41:23 2013
@@ -994,7 +994,7 @@
         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.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172301&r1=172300&r2=172301&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan 11 23:41:23 2013
@@ -956,6 +956,9 @@
                "case -1:\n"
                "  break;\n"
                "}");
+
+  verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { -5, +3 };");
+  verifyFormat("const NSPoint kBrowserFrameViewPatternOffset = { +5, -3 };");
 }
 
 TEST_F(FormatTest, UndestandsOverloadedOperators) {





More information about the cfe-commits mailing list