diff options
author | Daniel Jasper <djasper@google.com> | 2014-07-09 07:50:33 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2014-07-09 07:50:33 +0000 |
commit | 4355e7f0effc788f1af2b48a531f650e1e40db39 (patch) | |
tree | ac6f8ba9d24bf11533cbc84e7031767f34422d7f /clang/lib/Format/ContinuationIndenter.cpp | |
parent | 696b4a089cde5513973dc8e2cf17684d44e74aa5 (diff) | |
download | bcm5719-llvm-4355e7f0effc788f1af2b48a531f650e1e40db39.tar.gz bcm5719-llvm-4355e7f0effc788f1af2b48a531f650e1e40db39.zip |
clang-format: Revamp function declaration/definition indentation.
Key changes:
- Correctly (well ...) distinguish function declarations and variable
declarations with ()-initialization.
- Don't indent when breaking function declarations/definitions after the
return type.
- Indent variable declarations and typedefs when breaking after the
type.
This fixes llvm.org/PR17999.
llvm-svn: 212591
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 39baef69306..683bb69eacd 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -203,10 +203,12 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { !Current.isTrailingComment()) return true; - if ((Current.Type == TT_StartOfName || Current.is(tok::kw_operator)) && - State.Line->MightBeFunctionDecl && - State.Stack.back().BreakBeforeParameter && Current.NestingLevel == 0) + // If the return type spans multiple lines, wrap before the function name. + if ((Current.Type == TT_FunctionDeclarationName || + Current.is(tok::kw_operator)) && + State.Stack.back().BreakBeforeParameter) return true; + if (startsSegmentOfBuilderTypeCall(Current) && (State.Stack.back().CallContinuation != 0 || (State.Stack.back().BreakBeforeParameter && @@ -518,11 +520,8 @@ unsigned ContinuationIndenter::getNewLineColumn(const LineState &State) { return State.Stack.back().VariablePos; if ((PreviousNonComment && (PreviousNonComment->ClosesTemplateDeclaration || PreviousNonComment->Type == TT_AttributeParen)) || - ((NextNonComment->Type == TT_StartOfName || - NextNonComment->is(tok::kw_operator)) && - Current.NestingLevel == 0 && - (!Style.IndentFunctionDeclarationAfterType || - State.Line->StartsDefinition))) + NextNonComment->is(tok::kw_operator) || + NextNonComment->Type == TT_FunctionDeclarationName) return std::max(State.Stack.back().LastSpace, State.Stack.back().Indent); if (NextNonComment->Type == TT_SelectorName) { if (!State.Stack.back().ObjCSelectorNameFound) { |