From: Daniel Jasper Date: Thu, 11 Feb 2016 06:43:01 +0000 (+0000) Subject: clang-format: Make it more expensive to break template parameters. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c43284c4913e075fc10ac6dea2961788a660f09d;p=clang clang-format: Make it more expensive to break template parameters. In particular, make it more expensive than breaking after the return type of a function definition/declaration. Before: template aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa< T>::aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); After: template aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa::aaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260497 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index a53cceb9a3..9dcda5d383 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -59,7 +59,7 @@ private: FormatToken *Left = CurrentToken->Previous; Left->ParentBracket = Contexts.back().ContextKind; - ScopedContextCreator ContextCreator(*this, tok::less, 10); + ScopedContextCreator ContextCreator(*this, tok::less, 12); // If this angle is in the context of an expression, we need to be more // hesitant to detect it as opening template parameters. diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 8d541301a3..da8167ebf4 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3850,6 +3850,11 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) { "typename aaaaaaaaaa::aaaaaaaaaaa\n" "aaaaaaaaaa::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}"); + verifyGoogleFormat( + "template \n" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n" + "aaaaaaaaaaaaaaaaaaaaaaa::aaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);"); FormatStyle Style = getLLVMStyle(); Style.PointerAlignment = FormatStyle::PAS_Left;