From: Daniel Jasper Date: Fri, 15 Aug 2014 05:00:39 +0000 (+0000) Subject: clang-format: Prefer breaking after return type over template param X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa2040597b183d7c1ba55750abebd89d93838440;p=clang clang-format: Prefer breaking after return type over template param Before: typename aaaaaaaaaa::aaaaaaaaaaa aaaaaaaaaa< aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bool *aaaaaaaaaaaaaaaaaa, bool *aa) {} After: typename aaaaaaaaaa::aaaaaaaaaaa aaaaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( bool *aaaaaaaaaaaaaaaaaa, bool *aa) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@215693 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 0ac30a76ff..017a8404ba 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1441,6 +1441,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, return 110; if (Right.is(tok::r_brace)) return 1; + if (Left.Type == TT_TemplateOpener) + return 100; if (Left.opensScope()) return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter : 19; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index d8e20e9c2a..73d17d3910 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3428,6 +3428,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) { " int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1);"); verifyFormat("aaaaaaaaaaaaaaaaaaaaaa\n" "aaaaaaaaaaaaaaaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaa = 1);"); + verifyGoogleFormat( + "typename aaaaaaaaaa::aaaaaaaaaaa\n" + "aaaaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}"); } TEST_F(FormatTest, TrailingReturnType) {