r232112 - clang-format: [OBJC] Don't indent 8 spaces in method declarations.
Daniel Jasper
djasper at google.com
Thu Mar 12 15:13:45 PDT 2015
Author: djasper
Date: Thu Mar 12 17:13:45 2015
New Revision: 232112
URL: http://llvm.org/viewvc/llvm-project?rev=232112&view=rev
Log:
clang-format: [OBJC] Don't indent 8 spaces in method declarations.
Before:
- (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
(SoooooooooooooooooooooomeType *)bbbbbbbbbb;
After:
- (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
(SoooooooooooooooooooooomeType *)bbbbbbbbbb;
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=232112&r1=232111&r2=232112&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Mar 12 17:13:45 2015
@@ -307,7 +307,9 @@ void ContinuationIndenter::addTokenOnCur
else if (State.Stack.back().Indent + Current.LongestObjCSelectorName >
State.Column + Spaces + Current.ColumnWidth)
State.Stack.back().ColonPos =
- State.Stack.back().Indent + Current.LongestObjCSelectorName;
+ std::max(State.FirstIndent + Style.ContinuationIndentWidth,
+ State.Stack.back().Indent) +
+ Current.LongestObjCSelectorName;
else
State.Stack.back().ColonPos = State.Column + Spaces + Current.ColumnWidth;
}
@@ -648,12 +650,6 @@ unsigned ContinuationIndenter::moveState
State.Stack.back().BreakBeforeParameter = false;
}
- // In ObjC method declaration we align on the ":" of parameters, but we need
- // to ensure that we indent parameters on subsequent lines by at least our
- // continuation indent width.
- if (Current.is(TT_ObjCMethodSpecifier))
- State.Stack.back().Indent += Style.ContinuationIndentWidth;
-
// Insert scopes created by fake parenthesis.
const FormatToken *Previous = Current.getPreviousNonComment();
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=232112&r1=232111&r2=232112&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Mar 12 17:13:45 2015
@@ -6627,6 +6627,8 @@ TEST_F(FormatTest, FormatForObjectiveCMe
"- (void)sendAction:(SEL)aSelector to:(id)anObject forAllCells:(BOOL)flag;"));
// Very long objectiveC method declaration.
+ verifyFormat("- (void)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n"
+ " (SoooooooooooooooooooooomeType *)bbbbbbbbbb;");
verifyFormat("- (NSUInteger)indexOfObject:(id)anObject\n"
" inRange:(NSRange)range\n"
" outRange:(NSRange)out_range\n"
More information about the cfe-commits
mailing list