]> granicus.if.org Git - clang/commitdiff
Formatter: Don't put a space in ObjC number literals like @+50
authorNico Weber <nicolasweber@gmx.de>
Thu, 10 Jan 2013 19:36:35 +0000 (19:36 +0000)
committerNico Weber <nicolasweber@gmx.de>
Thu, 10 Jan 2013 19:36:35 +0000 (19:36 +0000)
Before:
@ -4.5

Now:
@-4.5

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172095 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 406daac7a62f241f00bdb7ca871a58ac05e0cf3f..4d281047b89484c12c476c8614e5481fc856b37f 100644 (file)
@@ -946,7 +946,8 @@ private:
     if (Tok.Parent->is(tok::equal) || Tok.Parent->is(tok::l_paren) ||
         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::kw_return) || Tok.Parent->is(tok::kw_case) ||
+        Tok.Parent->is(tok::at))
       return TT_UnaryOperator;
 
     // There can't be to consecutive binary operators.
@@ -1054,7 +1055,8 @@ private:
       return false;
     if (Tok.Type == TT_UnaryOperator)
       return Tok.Parent->isNot(tok::l_paren) &&
-             Tok.Parent->isNot(tok::l_square);
+             Tok.Parent->isNot(tok::l_square) &&
+             Tok.Parent->isNot(tok::at);
     if (Tok.Parent->is(tok::greater) && Tok.is(tok::greater)) {
       return Tok.Type == TT_TemplateCloser && Tok.Parent->Type ==
              TT_TemplateCloser && Style.SplitTemplateClosingGreater;
index 077c358c22b1d7aa7ae4678e79ecff659d5b106d..b55cad742eaa2cde24da44172639315b4d41c755 100644 (file)
@@ -1402,11 +1402,10 @@ TEST_F(FormatTest, ObjCAt) {
   verifyFormat("@throw");
   verifyFormat("@try");
 
-  // FIXME: Make the uncommented lines below pass.
   verifyFormat("@\"String\"");
   verifyFormat("@1");
-  //verifyFormat("@+4.8");
-  //verifyFormat("@-4");
+  verifyFormat("@+4.8");
+  verifyFormat("@-4");
   verifyFormat("@1LL");
   verifyFormat("@.5");
   verifyFormat("@'c'");