r201424 - clang-format: Fix formatting of class template declaration.
Daniel Jasper
djasper at google.com
Fri Feb 14 10:22:40 PST 2014
Author: djasper
Date: Fri Feb 14 12:22:40 2014
New Revision: 201424
URL: http://llvm.org/viewvc/llvm-project?rev=201424&view=rev
Log:
clang-format: Fix formatting of class template declaration.
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)> {};
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=201424&r1=201423&r2=201424&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Feb 14 12:22:40 2014
@@ -1503,6 +1503,8 @@ bool TokenAnnotator::canBreakBefore(cons
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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=201424&r1=201423&r2=201424&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Feb 14 12:22:40 2014
@@ -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) {
More information about the cfe-commits
mailing list