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.
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 &&
TEST_F(FormatTest, WrapsTemplateDeclarations) {
verifyFormat("template <typename T>\n"
"virtual void loooooooooooongFunction(int Param1, int Param2);");
+ verifyFormat("template <typename T>\n"
+ "// T should be one of {A, B}.\n"
+ "virtual void loooooooooooongFunction(int Param1, int Param2);");
verifyFormat(
"template <typename T>\n"
"using comment_to_xml_conversion = comment_to_xml_conversion<T, int>;");