diff options
author | Krasimir Georgiev <krasimir@google.com> | 2018-05-23 14:18:19 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2018-05-23 14:18:19 +0000 |
commit | 0fb19de0c3ac9057d44ac5a3bbfa9d0d332dfb8c (patch) | |
tree | 6ba38740b8d4302384f15db6f499e94ea82f942c /clang/lib | |
parent | 5c4fb4566d766d029c73b611feab55c67662b332 (diff) | |
download | bcm5719-llvm-0fb19de0c3ac9057d44ac5a3bbfa9d0d332dfb8c.tar.gz bcm5719-llvm-0fb19de0c3ac9057d44ac5a3bbfa9d0d332dfb8c.zip |
[clang-format] Break template declarations followed by comments
Summary:
This patch fixes two bugs in clang-format where the template wrapper doesn't skip over
comments causing a long template declaration to not be split into multiple lines.
These were latent and exposed by r332436.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D47257
llvm-svn: 333085
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 441df05a52d..eacdfdc6e05 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -405,7 +405,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { // If the template declaration spans multiple lines, force wrap before the // function/class declaration if (Previous.ClosesTemplateDeclaration && - State.Stack.back().BreakBeforeParameter) + State.Stack.back().BreakBeforeParameter && Current.CanBreakBefore) return true; if (State.Column <= NewLineColumn) @@ -804,7 +804,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, !State.Stack.back().AvoidBinPacking) || Previous.is(TT_BinaryOperator)) State.Stack.back().BreakBeforeParameter = false; - if (Previous.isOneOf(TT_TemplateCloser, TT_JavaAnnotation) && + if (PreviousNonComment && + PreviousNonComment->isOneOf(TT_TemplateCloser, TT_JavaAnnotation) && Current.NestingLevel == 0) State.Stack.back().BreakBeforeParameter = false; if (NextNonComment->is(tok::question) || |