forked from OSchip/llvm-project
clang-format: Fix corner-case in ObjC method declaration formatting
Before: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } After: - (void)shortf:(GTMFoo *)theFoo longKeyword:(NSRect)theRect longerKeyword:(float)theInterval error:(NSError **)theError { } llvm-svn: 256738
This commit is contained in:
parent
ffbad0e8aa
commit
06a269574c
|
@ -317,16 +317,16 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
|
|||
|
||||
if (Current.is(TT_SelectorName) &&
|
||||
!State.Stack.back().ObjCSelectorNameFound) {
|
||||
unsigned MinIndent =
|
||||
std::max(State.FirstIndent + Style.ContinuationIndentWidth,
|
||||
State.Stack.back().Indent);
|
||||
unsigned FirstColonPos = State.Column + Spaces + Current.ColumnWidth;
|
||||
if (Current.LongestObjCSelectorName == 0)
|
||||
State.Stack.back().AlignColons = false;
|
||||
else if (State.Stack.back().Indent + Current.LongestObjCSelectorName >
|
||||
State.Column + Spaces + Current.ColumnWidth)
|
||||
State.Stack.back().ColonPos =
|
||||
std::max(State.FirstIndent + Style.ContinuationIndentWidth,
|
||||
State.Stack.back().Indent) +
|
||||
Current.LongestObjCSelectorName;
|
||||
else if (MinIndent + Current.LongestObjCSelectorName > FirstColonPos)
|
||||
State.Stack.back().ColonPos = MinIndent + Current.LongestObjCSelectorName;
|
||||
else
|
||||
State.Stack.back().ColonPos = State.Column + Spaces + Current.ColumnWidth;
|
||||
State.Stack.back().ColonPos = FirstColonPos;
|
||||
}
|
||||
|
||||
// In "AlwaysBreak" mode, enforce wrapping directly after the parenthesis by
|
||||
|
|
|
@ -467,9 +467,8 @@ private:
|
|||
Tok->Type = TT_ObjCMethodExpr;
|
||||
Tok->Previous->Type = TT_SelectorName;
|
||||
if (Tok->Previous->ColumnWidth >
|
||||
Contexts.back().LongestObjCSelectorName) {
|
||||
Contexts.back().LongestObjCSelectorName)
|
||||
Contexts.back().LongestObjCSelectorName = Tok->Previous->ColumnWidth;
|
||||
}
|
||||
if (!Contexts.back().FirstObjCSelectorName)
|
||||
Contexts.back().FirstObjCSelectorName = Tok->Previous;
|
||||
} else if (Contexts.back().ColonIsForRangeExpr) {
|
||||
|
|
|
@ -7280,6 +7280,11 @@ TEST_F(FormatTest, FormatObjCMethodDeclarations) {
|
|||
" rect:(NSRect)theRect\n"
|
||||
" interval:(float)theInterval {\n"
|
||||
"}");
|
||||
verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n"
|
||||
" longKeyword:(NSRect)theRect\n"
|
||||
" longerKeyword:(float)theInterval\n"
|
||||
" error:(NSError **)theError {\n"
|
||||
"}");
|
||||
verifyFormat("- (void)shortf:(GTMFoo *)theFoo\n"
|
||||
" longKeyword:(NSRect)theRect\n"
|
||||
" evenLongerKeyword:(float)theInterval\n"
|
||||
|
|
Loading…
Reference in New Issue