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 <typename T>
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa<
      T>::aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);

After:
  template <typename T>
  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa(
      aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);

llvm-svn: 260497
This commit is contained in:
Daniel Jasper 2016-02-11 06:43:01 +00:00
parent 7f550f3dbb
commit 88db760e4b
2 changed files with 6 additions and 1 deletions

View File

@ -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.

View File

@ -3850,6 +3850,11 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
"typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa\n"
"aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}");
verifyGoogleFormat(
"template <typename T>\n"
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
"aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa);");
FormatStyle Style = getLLVMStyle();
Style.PointerAlignment = FormatStyle::PAS_Left;