r174513 - Fix formatting of ObjC method calls.

Nico Weber thakis at chromium.org
Wed Feb 6 08:25:59 PST 2013


On Wed, Feb 6, 2013 at 8:00 AM, Daniel Jasper <djasper at google.com> wrote:
> Author: djasper
> Date: Wed Feb  6 10:00:26 2013
> New Revision: 174513
>
> URL: http://llvm.org/viewvc/llvm-project?rev=174513&view=rev
> Log:
> Fix formatting of ObjC method calls.

Thanks! With this and r174498, clang-format suddenly becomes useful
for Objective-C code. I went through a few files in Chromium, and
clang-format formats almost everything better or at least as good as
what is currently there.

>
> This fixes llvm.org/PR15165.
>
> We now correctly align:
>   [image_rep drawInRect:drawRect
>                fromRect:NSZeroRect
>               operation:NSCompositeCopy
>                fraction:1.0
>              ssssssssdd:NO
>                   hints:nil];
>
> 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=174513&r1=174512&r2=174513&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Format/Format.cpp (original)
> +++ cfe/trunk/lib/Format/Format.cpp Wed Feb  6 10:00:26 2013
> @@ -488,7 +488,7 @@ private:
>                State.Stack.back().Indent + Current.LongestObjCSelectorName;
>          else
>            State.Stack.back().ColonPos =
> -              State.Column + Spaces + Current.LongestObjCSelectorName;
> +              State.Column + Spaces + Current.FormatTok.TokenLength;
>        }
>
>        // FIXME: Do we need to do this for assignments nested in other
>
> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=174513&r1=174512&r2=174513&view=diff
> ==============================================================================
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Feb  6 10:00:26 2013
> @@ -2381,6 +2381,12 @@ TEST_F(FormatTest, FormatObjCMethodExpr)
>                 "                  selector:@selector(willEnterFullscreen)\n"
>                 "                      name:kWillEnterFullscreenNotification\n"
>                 "                    object:nil];");
> +  verifyFormat("[image_rep drawInRect:drawRect\n"
> +               "             fromRect:NSZeroRect\n"
> +               "            operation:NSCompositeCopy\n"
> +               "             fraction:1.0\n"
> +               "       respectFlipped:NO\n"
> +               "                hints:nil];");
>  }
>
>  TEST_F(FormatTest, ObjCAt) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list