aboutsummaryrefslogtreecommitdiff
path: root/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-24 18:54:32 +0000
committerDaniel Jasper <djasper@google.com>2013-02-24 18:54:32 +0000
commit3c08a818a6ac9115fe8880af9bbf5a0a87bdffaa (patch)
tree71d8f4b480a6ebe59924a08aee7323aa08318d60 /unittests/Format/FormatTest.cpp
parent960876cd88a9aba546345dec49a1cf9a4f248356 (diff)
Allow breaking between a type and name in variable declarations.
This fixes llvm.org/PR14967 and is generall necessary to avoid situations where the column limit is exceeded. The challenge is restricting such lines splits, otherwise clang-format suddenly starts breaking at bad places. Before: ReallyLongReturnType<TemplateParam1, TemplateParam2> ReallyReallyLongFunctionName( const std::string &SomeParameter, const SomeType<string, SomeOtherTemplateParameter> &ReallyReallyLongParameterName, const SomeType<string, SomeOtherTemplateParameter> &AnotherLongParameterName) {} After: ReallyLongReturnType<TemplateParam1, TemplateParam2> ReallyReallyLongFunctionName( const std::string &SomeParameter, const SomeType<string, SomeOtherTemplateParameter> & ReallyReallyLongParameterName, const SomeType<string, SomeOtherTemplateParameter> & AnotherLongParameterName) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175999 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/FormatTest.cpp')
-rw-r--r--unittests/Format/FormatTest.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 2f8097c612..94ac4cf59f 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1931,13 +1931,24 @@ TEST_F(FormatTest, FormatsFunctionTypes) {
verifyFormat("int(*func)(void *);");
}
-TEST_F(FormatTest, BreaksFunctionDeclarations) {
+TEST_F(FormatTest, BreaksLongDeclarations) {
verifyFormat("int *someFunction(int LoooooooooooooooooooongParam1,\n"
" int LoooooooooooooooooooongParam2) {}");
verifyFormat(
"TypeSpecDecl *\n"
"TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,\n"
" IdentifierIn *II, Type *T) {}");
+ verifyFormat("ReallyLongReturnType<TemplateParam1, TemplateParam2>\n"
+ "ReallyReallyLongFunctionName(\n"
+ " const std::string &SomeParameter,\n"
+ " const SomeType<string, SomeOtherTemplateParameter> &\n"
+ " ReallyReallyLongParameterName,\n"
+ " const SomeType<string, SomeOtherTemplateParameter> &\n"
+ " AnotherLongParameterName) {}");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaa::aaaaaaaaaaaaaaaa<aaaaaaaaaaaaa, aaaaaaaaaaaa>\n"
+ "aaaaaaaaaaaaaaaaaaaaaaa;");
+
verifyGoogleFormat(
"TypeSpecDecl* TypeSpecDecl::Create(\n"
" ASTContext& C, DeclContext* DC, SourceLocation L) {}");