]> granicus.if.org Git - clang/commitdiff
clang-format: Make it more expensive to break template parameters.
authorDaniel Jasper <djasper@google.com>
Thu, 11 Feb 2016 06:43:01 +0000 (06:43 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 11 Feb 2016 06:43:01 +0000 (06:43 +0000)
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);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260497 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index a53cceb9a30f6d14ae55600df4761fccb2566ee2..9dcda5d3839ec3e4a3cc5047b7844d979f5f23bb 100644 (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.
index 8d541301a33bea4d69adbac7a7a8292c09428ee0..da8167ebf4c4b3558d50da8515dc8f0339fee4ae 100644 (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;