aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Format/Format.cpp3
-rw-r--r--unittests/Format/FormatTest.cpp5
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 3c337ec063..6fb75a657a 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -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;
}
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 574d685fbd..eac8f4c7f3 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -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);");
}