Current->Next->is(tok::string_literal)) {
Current->MustBreakBefore = true;
} else if (Current->Previous->ClosesTemplateDeclaration &&
+ Current->Previous->MatchingParen &&
+ Current->Previous->MatchingParen->BindingStrength == 1 &&
Style.AlwaysBreakTemplateDeclarations) {
+ // FIXME: Fix horrible hack of using BindingStrength to find top-level <>.
Current->MustBreakBefore = true;
} else if (Current->Type == TT_CtorInitializerComma &&
Style.BreakConstructorInitializersBeforeComma) {
verifyFormat("template <typename T> class C {};");
verifyFormat("template <typename T> void f();");
verifyFormat("template <typename T> void f() {}");
-
- FormatStyle AlwaysBreak = getLLVMStyle();
- AlwaysBreak.AlwaysBreakTemplateDeclarations = true;
- verifyFormat("template <typename T>\nclass C {};", AlwaysBreak);
- verifyFormat("template <typename T>\nvoid f();", AlwaysBreak);
- verifyFormat("template <typename T>\nvoid f() {}", AlwaysBreak);
- verifyFormat("void aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
- " bbbbbbbbbbbbbbbbbbbbbbbbbbbb>(\n"
- " ccccccccccccccccccccccccccccccccccccccccccccccc);");
verifyFormat(
"aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(\n"
" bbbbbbbbbbbbbbbbbbbbbbbb);",
getLLVMStyleWithColumns(72));
+
+ FormatStyle AlwaysBreak = getLLVMStyle();
+ AlwaysBreak.AlwaysBreakTemplateDeclarations = true;
+ verifyFormat("template <typename T>\nclass C {};", AlwaysBreak);
+ verifyFormat("template <typename T>\nvoid f();", AlwaysBreak);
+ verifyFormat("template <typename T>\nvoid f() {}", AlwaysBreak);
+ verifyFormat("void aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " bbbbbbbbbbbbbbbbbbbbbbbbbbbb>(\n"
+ " ccccccccccccccccccccccccccccccccccccccccccccccc);");
+ verifyFormat("template <template <typename> class Fooooooo,\n"
+ " template <typename> class Baaaaaaar>\n"
+ "struct C {};",
+ AlwaysBreak);
}
TEST_F(FormatTest, WrapsAtNestedNameSpecifiers) {