summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-04-09 10:29:11 +0000
committerDaniel Jasper <djasper@google.com>2014-04-09 10:29:11 +0000
commitf9a0906b980cf76aa2e7a3518782703cc69dc09b (patch)
tree3bcb769b355f7fb757bc821d4b846ec25d3bdc2f
parentb48d3afcd53e16712f55836a81f08a1d65953540 (diff)
downloadbcm5719-llvm-f9a0906b980cf76aa2e7a3518782703cc69dc09b.tar.gz
bcm5719-llvm-f9a0906b980cf76aa2e7a3518782703cc69dc09b.zip
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
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp10
-rw-r--r--clang/unittests/Format/FormatTest.cpp2
2 files changed, 7 insertions, 5 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index cd05a6807e6..a0109713a6a 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index e3da016663c..b9310abbbea 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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"
OpenPOWER on IntegriCloud