diff options
author | Daniel Jasper <djasper@google.com> | 2013-09-27 07:49:08 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-09-27 07:49:08 +0000 |
commit | 69bd8fb79a44f9173f98ae478735f58d7bb940f4 (patch) | |
tree | 1e4a858f8ae873f75d3776c90123f21ac1b36093 /clang/lib | |
parent | 74e38de492c929b897002b393d07a329d9b1623d (diff) | |
download | bcm5719-llvm-69bd8fb79a44f9173f98ae478735f58d7bb940f4.tar.gz bcm5719-llvm-69bd8fb79a44f9173f98ae478735f58d7bb940f4.zip |
clang-format: Fix formatting bug with comment in weird place.
Before:
template <typename T>
// T should be one of {A, B}.
void f() {}
After:
template <typename T>
// T should be one of {A, B}.
void f() {}
llvm-svn: 191492
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 87c022294e4..8b0baead67a 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -192,6 +192,8 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline, unsigned ExtraSpaces) { const FormatToken &Current = *State.NextToken; const FormatToken &Previous = *State.NextToken->Previous; + const FormatToken *PreviousNonComment = + State.NextToken->getPreviousNonComment(); // Extra penalty that needs to be added because of the way certain line // breaks are chosen. @@ -253,7 +255,8 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline, State.Column = State.Stack.back().QuestionColumn; } else if (Previous.is(tok::comma) && State.Stack.back().VariablePos != 0) { State.Column = State.Stack.back().VariablePos; - } else if (Previous.ClosesTemplateDeclaration || + } else if ((PreviousNonComment && + PreviousNonComment->ClosesTemplateDeclaration) || ((Current.Type == TT_StartOfName || Current.is(tok::kw_operator)) && State.ParenLevel == 0 && |