diff options
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 6 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index eea9d67e693..5a925e6140b 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1538,7 +1538,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, return 200; } if (Right.is(TT_PointerOrReference)) - return 200; + return 190; if (Right.is(TT_TrailingReturnArrow)) return 110; if (Left.is(tok::equal) && Right.is(tok::l_brace)) @@ -1995,8 +1995,6 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, return false; if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation)) return !Right.is(tok::l_paren); - if (Left.is(TT_PointerOrReference)) - return Right.is(TT_FunctionDeclarationName); if (Right.is(TT_PointerOrReference)) return Line.IsMultiVariableDeclStmt || (Style.PointerAlignment == FormatStyle::PAS_Right && @@ -2004,6 +2002,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, if (Right.isOneOf(TT_StartOfName, TT_FunctionDeclarationName) || Right.is(tok::kw_operator)) return true; + if (Left.is(TT_PointerOrReference)) + return false; if (Right.isTrailingComment()) // We rely on MustBreakBefore being set correctly here as we should not // change the "binding" behavior of a comment. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 228e952bd1e..3887ca0f228 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -3780,6 +3780,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) { verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {}", Style); + verifyFormat( + "void aaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}", + Style); } TEST_F(FormatTest, TrailingReturnType) { |

