r174843 - Formatter: Remove now-unneeded code for formatting ':'s in ObjC method decls.

Nico Weber nicolasweber at gmx.de
Sun Feb 10 13:08:32 PST 2013


Author: nico
Date: Sun Feb 10 15:08:31 2013
New Revision: 174843

URL: http://llvm.org/viewvc/llvm-project?rev=174843&view=rev
Log:
Formatter: Remove now-unneeded code for formatting ':'s in ObjC method decls.

The more general code for formatting ObjC method exprs does this and more,
it's no longer necessary to special-case this. No behavior change.


Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=174843&r1=174842&r2=174843&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sun Feb 10 15:08:31 2013
@@ -963,19 +963,11 @@ bool TokenAnnotator::spaceRequiredBetwee
 bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
                                          const AnnotatedToken &Tok) {
   if (Line.Type == LT_ObjCMethodDecl) {
-    if (Tok.is(tok::identifier) && !Tok.Children.empty() &&
-        Tok.Children[0].is(tok::colon) && Tok.Parent->is(tok::identifier))
-      return true;
-    if (Tok.is(tok::colon))
-      return false;
     if (Tok.Parent->Type == TT_ObjCMethodSpecifier)
       return true;
     if (Tok.Parent->is(tok::r_paren) && Tok.is(tok::identifier))
       // Don't space between ')' and <id>
       return false;
-    if (Tok.Parent->is(tok::colon) && Tok.is(tok::l_paren))
-      // Don't space between ':' and '('
-      return false;
   }
   if (Line.Type == LT_ObjCProperty &&
       (Tok.is(tok::equal) || Tok.Parent->is(tok::equal)))
@@ -1019,19 +1011,6 @@ bool TokenAnnotator::spaceRequiredBefore
 bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
                                     const AnnotatedToken &Right) {
   const AnnotatedToken &Left = *Right.Parent;
-  if (Line.Type == LT_ObjCMethodDecl) {
-    if (Right.is(tok::identifier) && !Right.Children.empty() &&
-        Right.Children[0].is(tok::colon) && Left.is(tok::identifier))
-      return true;
-    if (Right.is(tok::identifier) && Left.is(tok::l_paren) &&
-        Left.Parent->is(tok::colon))
-      // Don't break this identifier as ':' or identifier
-      // before it will break.
-      return false;
-    if (Right.is(tok::colon) && Left.is(tok::identifier) && Left.CanBreakBefore)
-      // Don't break at ':' if identifier before it can beak.
-      return false;
-  }
   if (Right.Type == TT_StartOfName && Style.AllowReturnTypeOnItsOwnLine)
     return true;
   if (Right.is(tok::colon) && Right.Type == TT_ObjCMethodExpr)





More information about the cfe-commits mailing list