summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-05-15 09:35:08 +0000
committerDaniel Jasper <djasper@google.com>2013-05-15 09:35:08 +0000
commitc6fbc2192c0d8d0b1f4eb9b1154d730b7c93c6cf (patch)
treef9da96faca35f24f20f671dcc20cc7e838c890fd /clang/lib/Format/Format.cpp
parente2af9ea00f15eb494b69ba4d4e7f424d4c3a7de9 (diff)
downloadbcm5719-llvm-c6fbc2192c0d8d0b1f4eb9b1154d730b7c93c6cf.tar.gz
bcm5719-llvm-c6fbc2192c0d8d0b1f4eb9b1154d730b7c93c6cf.zip
Break function declarations after multi-line return types.
Before: template <typename A> SomeLoooooooooooooooooooooongType< typename some_namespace::SomeOtherType<A>::Type> Function() {} After: template <typename A> SomeLoooooooooooooooooooooongType< typename some_namespace::SomeOtherType<A>::Type> Function() {} llvm-svn: 181877
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 99521ea8ccd..9e882157aa7 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -504,6 +504,8 @@ private:
!State.Stack.back().AvoidBinPacking) ||
Previous.Type == TT_BinaryOperator)
State.Stack.back().BreakBeforeParameter = false;
+ if (Previous.Type == TT_TemplateCloser && State.ParenLevel == 0)
+ State.Stack.back().BreakBeforeParameter = false;
if (!DryRun) {
unsigned NewLines = 1;
@@ -531,6 +533,7 @@ private:
}
const AnnotatedToken *TokenBefore = Current.getPreviousNoneComment();
if (TokenBefore && !TokenBefore->isOneOf(tok::comma, tok::semi) &&
+ TokenBefore->Type != TT_TemplateCloser &&
TokenBefore->Type != TT_BinaryOperator && !TokenBefore->opensScope())
State.Stack.back().BreakBeforeParameter = true;
@@ -1017,6 +1020,10 @@ private:
getRemainingLength(State) + State.Column > getColumnLimit() &&
State.ParenLevel < State.StartOfLineLevel)
return true;
+
+ if (Current.Type == TT_StartOfName && Line.MightBeFunctionDecl &&
+ State.Stack.back().BreakBeforeParameter && State.ParenLevel == 0)
+ return true;
return false;
}
OpenPOWER on IntegriCloud