forked from OSchip/llvm-project
Allow breaking before a trailing const.
Before: void someLongFunction( int someLongParameter) const; After: void someLongFunction(int someLongParameter) const; Also slightly cleanup tests. llvm-svn: 182362
This commit is contained in:
parent
4059d778d1
commit
5be31f728a
|
@ -1187,7 +1187,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
|
||||||
tok::kw_class, tok::kw_struct) ||
|
tok::kw_class, tok::kw_struct) ||
|
||||||
Right.isOneOf(tok::lessless, tok::arrow, tok::period, tok::colon) ||
|
Right.isOneOf(tok::lessless, tok::arrow, tok::period, tok::colon) ||
|
||||||
(Left.is(tok::r_paren) && Left.Type != TT_CastRParen &&
|
(Left.is(tok::r_paren) && Left.Type != TT_CastRParen &&
|
||||||
Right.isOneOf(tok::identifier, tok::kw___attribute)) ||
|
Right.isOneOf(tok::identifier, tok::kw_const, tok::kw___attribute)) ||
|
||||||
(Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
|
(Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
|
||||||
(Left.is(tok::l_square) && !Right.is(tok::r_square));
|
(Left.is(tok::l_square) && !Right.is(tok::r_square));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1628,12 +1628,6 @@ TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) {
|
||||||
// Line break tests.
|
// Line break tests.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
TEST_F(FormatTest, FormatsFunctionDefinition) {
|
|
||||||
verifyFormat("void f(int a, int b, int c, int d, int e, int f, int g,"
|
|
||||||
" int h, int j, int f,\n"
|
|
||||||
" int c, int ddddddddddddd) {}");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(FormatTest, FormatsAwesomeMethodCall) {
|
TEST_F(FormatTest, FormatsAwesomeMethodCall) {
|
||||||
verifyFormat(
|
verifyFormat(
|
||||||
"SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n"
|
"SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n"
|
||||||
|
@ -1914,6 +1908,30 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
|
||||||
" bbbb bbbb);");
|
" bbbb bbbb);");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) {
|
||||||
|
verifyFormat("void someLongFunction(int someLongParameter)\n"
|
||||||
|
" const;",
|
||||||
|
getLLVMStyleWithColumns(45));
|
||||||
|
|
||||||
|
verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
|
||||||
|
" LOCKS_EXCLUDED(aaaaaaaaaaaaa);");
|
||||||
|
verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
|
||||||
|
" LOCKS_EXCLUDED(aaaaaaaaaaaaa);");
|
||||||
|
verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
|
||||||
|
" LOCKS_EXCLUDED(aaaaaaaaaaaaa) {}");
|
||||||
|
|
||||||
|
verifyFormat(
|
||||||
|
"void aaaaaaaaaaaaaaaaaa()\n"
|
||||||
|
" __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n"
|
||||||
|
" aaaaaaaaaaaaaaaaaaaaaaaaa));");
|
||||||
|
verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
|
||||||
|
" __attribute__((unused));");
|
||||||
|
verifyFormat(
|
||||||
|
"bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
|
||||||
|
" GUARDED_BY(aaaaaaaaaaaa);");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_F(FormatTest, BreaksDesireably) {
|
TEST_F(FormatTest, BreaksDesireably) {
|
||||||
verifyFormat("if (aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n"
|
verifyFormat("if (aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n"
|
||||||
" aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n"
|
" aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaa) ||\n"
|
||||||
|
@ -2051,24 +2069,6 @@ TEST_F(FormatTest, FormatsBuilderPattern) {
|
||||||
" ->aaaaaaaaaaaaaaaaa();");
|
" ->aaaaaaaaaaaaaaaaa();");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTest, DoesNotBreakTrailingAnnotation) {
|
|
||||||
verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
|
|
||||||
" LOCKS_EXCLUDED(aaaaaaaaaaaaa);");
|
|
||||||
verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
|
|
||||||
" LOCKS_EXCLUDED(aaaaaaaaaaaaa);");
|
|
||||||
verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
|
|
||||||
" LOCKS_EXCLUDED(aaaaaaaaaaaaa) {}");
|
|
||||||
verifyFormat(
|
|
||||||
"void aaaaaaaaaaaaaaaaaa()\n"
|
|
||||||
" __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa,\n"
|
|
||||||
" aaaaaaaaaaaaaaaaaaaaaaaaa));");
|
|
||||||
verifyFormat("bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
|
|
||||||
" __attribute__((unused));");
|
|
||||||
verifyFormat(
|
|
||||||
"bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
|
|
||||||
" GUARDED_BY(aaaaaaaaaaaa);");
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
|
TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
|
||||||
verifyFormat(
|
verifyFormat(
|
||||||
"if (aaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
|
"if (aaaaaaaaaaaaaaaaaaaaaaaaa ||\n"
|
||||||
|
|
Loading…
Reference in New Issue