]> granicus.if.org Git - clang/commitdiff
clang-format: Fix formatting of class template declaration.
authorDaniel Jasper <djasper@google.com>
Fri, 14 Feb 2014 18:22:40 +0000 (18:22 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 14 Feb 2014 18:22:40 +0000 (18:22 +0000)
Before:
  template <class R, class C>
  struct Aaaaaaaaaaaaaaaaa<R (C::*)(int)
                           const> : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};

After:
  template <class R, class C>
  struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const>
      : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};

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

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

index 6891930ead30eb8c5ecafdb76335ac1b1e48e45b..2275557fda41d6fa37388cd121e7e9e0d289a345 100644 (file)
@@ -1503,6 +1503,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
   if (Right.is(tok::colon) &&
       (Right.Type == TT_DictLiteral || Right.Type == TT_ObjCMethodExpr))
     return false;
+  if (Right.Type == TT_InheritanceColon)
+    return true;
   if (Left.is(tok::colon) &&
       (Left.Type == TT_DictLiteral || Left.Type == TT_ObjCMethodExpr))
     return true;
index a79379963b1c636515f5aa0c7a577240126c5b36..c4793a9c3025c57c8de065fd2fbad67916b526f4 100644 (file)
@@ -1625,6 +1625,9 @@ TEST_F(FormatTest, FormatsClasses) {
   verifyFormat("struct aaaaaaaaaaaaaaaaaaaa\n"
                "    : public aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaa,\n"
                "                                 aaaaaaaaaaaaaaaaaaaaaa> {};");
+  verifyFormat("template <class R, class C>\n"
+               "struct Aaaaaaaaaaaaaaaaa<R (C::*)(int) const>\n"
+               "    : Aaaaaaaaaaaaaaaaa<R (C::*)(int)> {};");
 }
 
 TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {