r174513 - Fix formatting of ObjC method calls.
Daniel Jasper
djasper at google.com
Wed Feb 6 08:00:26 PST 2013
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.
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) {
More information about the cfe-commits
mailing list