forked from OSchip/llvm-project
clang-format: Fix template declaration line breaking with comment.
Before, clang-format would always insert a linebreak before the comment in code like: template <typename T> // T can be A, B or C. struct S {}; llvm-svn: 192297
This commit is contained in:
parent
76a3c33d41
commit
d3e014d404
|
@ -178,7 +178,8 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
|
|||
State.Stack.back().BreakBeforeParameter)
|
||||
return true;
|
||||
if ((Current.Type == TT_CtorInitializerColon ||
|
||||
(Previous.ClosesTemplateDeclaration && State.ParenLevel == 0)))
|
||||
(Previous.ClosesTemplateDeclaration && State.ParenLevel == 0 &&
|
||||
!Current.isTrailingComment())))
|
||||
return true;
|
||||
|
||||
if ((Current.Type == TT_StartOfName || Current.is(tok::kw_operator)) &&
|
||||
|
|
|
@ -3586,6 +3586,9 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
|
|||
" template <typename> class Baaaaaaar>\n"
|
||||
"struct C {};",
|
||||
AlwaysBreak);
|
||||
verifyFormat("template <typename T> // T can be A, B or C.\n"
|
||||
"struct C {};",
|
||||
AlwaysBreak);
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {
|
||||
|
|
Loading…
Reference in New Issue