r205846 - clang-format: Allow breaking between trailing annotations in more cases.
Daniel Jasper
djasper at google.com
Wed Apr 9 03:29:11 PDT 2014
Author: djasper
Date: Wed Apr 9 05:29:11 2014
New Revision: 205846
URL: http://llvm.org/viewvc/llvm-project?rev=205846&view=rev
Log:
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);
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=205846&r1=205845&r2=205846&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Apr 9 05:29:11 2014
@@ -1623,11 +1623,11 @@ bool TokenAnnotator::canBreakBefore(cons
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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=205846&r1=205845&r2=205846&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Apr 9 05:29:11 2014
@@ -3295,6 +3295,8 @@ TEST_F(FormatTest, BreaksFunctionDeclara
" 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"
More information about the cfe-commits
mailing list