From: Daniel Jasper Date: Fri, 14 Feb 2014 18:22:40 +0000 (+0000) Subject: clang-format: Fix formatting of class template declaration. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cafca2019fcd2fca5dccef78e2a436e8b1d92da7;p=clang clang-format: Fix formatting of class template declaration. Before: template struct Aaaaaaaaaaaaaaaaa : Aaaaaaaaaaaaaaaaa {}; After: template struct Aaaaaaaaaaaaaaaaa : Aaaaaaaaaaaaaaaaa {}; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201424 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 6891930ead..2275557fda 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index a79379963b..c4793a9c30 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -1625,6 +1625,9 @@ TEST_F(FormatTest, FormatsClasses) { verifyFormat("struct aaaaaaaaaaaaaaaaaaaa\n" " : public aaaaaaaaaaaaaaaaaaa {};"); + verifyFormat("template \n" + "struct Aaaaaaaaaaaaaaaaa\n" + " : Aaaaaaaaaaaaaaaaa {};"); } TEST_F(FormatTest, FormatsVariableDeclarationsAfterStructOrClass) {