forked from OSchip/llvm-project
clang-format: Allow breaking between trailing annotations in more cases.
Before: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA( aaaaaaaaaaaaaaa); After: void aaaaaaaaaaaaaa(aaaaaaaa aaa) override AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa); llvm-svn: 205846
This commit is contained in:
parent
b48d3afcd5
commit
f9a0906b98
|
@ -1623,11 +1623,11 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
|
|||
if (Right.is(tok::r_brace))
|
||||
return Right.MatchingParen && Right.MatchingParen->BlockKind == BK_Block;
|
||||
|
||||
// Allow breaking after a trailing 'const', e.g. after a method declaration,
|
||||
// unless it is follow by ';', '{' or '='.
|
||||
if (Left.is(tok::kw_const) && Left.Previous != NULL &&
|
||||
Left.Previous->is(tok::r_paren))
|
||||
return !Right.isOneOf(tok::l_brace, tok::semi, tok::equal);
|
||||
// Allow breaking after a trailing annotation, e.g. after a method
|
||||
// declaration.
|
||||
if (Left.Type == TT_TrailingAnnotation)
|
||||
return !Right.isOneOf(tok::l_brace, tok::semi, tok::equal, tok::l_paren,
|
||||
tok::less, tok::coloncolon);
|
||||
|
||||
if (Right.is(tok::kw___attribute))
|
||||
return true;
|
||||
|
|
|
@ -3295,6 +3295,8 @@ TEST_F(FormatTest, BreaksFunctionDeclarationsWithTrailingTokens) {
|
|||
" LOCKS_EXCLUDED(aaaaaaaaaaaaa);");
|
||||
verifyFormat("void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const\n"
|
||||
" LOCKS_EXCLUDED(aaaaaaaaaaaaa) {}");
|
||||
verifyGoogleFormat("void aaaaaaaaaaaaaa(aaaaaaaa aaa) override\n"
|
||||
" AAAAAAAAAAAAAAAAAAAAAAAA(aaaaaaaaaaaaaaa);");
|
||||
|
||||
verifyFormat(
|
||||
"void aaaaaaaaaaaaaaaaaa()\n"
|
||||
|
|
Loading…
Reference in New Issue