summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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