Don't allow line breaks after template parameters.
This fixes llvm.org/PR14786. We will need to split there as a last resort, but that should be done consistently independent of whether the type is a template type or not. Before: template <typename T> aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa<T> ::aaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: template <typename T> aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); llvm-svn: 171400
This commit is contained in:
parent
98c844fd89
commit
90e51fdbab
|
@ -941,7 +941,10 @@ private:
|
|||
}
|
||||
|
||||
bool canBreakBefore(unsigned i) {
|
||||
if (Annotations[i - 1].ClosesTemplateDeclaration)
|
||||
return true;
|
||||
if (Annotations[i - 1].Type == TokenAnnotation::TT_PointerOrReference ||
|
||||
Annotations[i - 1].Type == TokenAnnotation::TT_TemplateCloser ||
|
||||
Annotations[i].Type == TokenAnnotation::TT_ConditionalExpr) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -636,6 +636,11 @@ TEST_F(FormatTest, WrapsTemplateDeclarations) {
|
|||
"template <typename T>\n"
|
||||
"void looooooooooooooooooooongFunction(int Paaaaaaaaaaaaaaaaaaaaram1,\n"
|
||||
" int Paaaaaaaaaaaaaaaaaaaaram2);");
|
||||
verifyFormat(
|
||||
"template <typename T>\n"
|
||||
"aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa,\n"
|
||||
" aaaaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaa,\n"
|
||||
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue