r214300 - clang-format: Understand 'typename' in placement new.
Daniel Jasper
djasper at google.com
Wed Jul 30 05:14:11 PDT 2014
Author: djasper
Date: Wed Jul 30 07:14:10 2014
New Revision: 214300
URL: http://llvm.org/viewvc/llvm-project?rev=214300&view=rev
Log:
clang-format: Understand 'typename' in placement new.
Before:
new (aaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa();
After:
new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))
typename aaaaaaaaaaaaaaaaaaaaaaaa();
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=214300&r1=214299&r2=214300&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jul 30 07:14:10 2014
@@ -1811,7 +1811,8 @@ bool TokenAnnotator::canBreakBefore(cons
Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace,
tok::kw_class, tok::kw_struct) ||
Right.isMemberAccess() ||
- Right.isOneOf(tok::lessless, tok::colon, tok::l_square, tok::at) ||
+ Right.isOneOf(tok::lessless, tok::colon, tok::l_square, tok::at,
+ tok::kw_typename) ||
(Left.is(tok::r_paren) &&
Right.isOneOf(tok::identifier, tok::kw_const)) ||
(Left.is(tok::l_paren) && !Right.is(tok::r_paren));
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=214300&r1=214299&r2=214300&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jul 30 07:14:10 2014
@@ -4714,6 +4714,8 @@ TEST_F(FormatTest, UnderstandsNewAndDele
" delete a;\n"
" delete (A *)a;\n"
"}");
+ verifyFormat("new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n"
+ " typename aaaaaaaaaaaaaaaaaaaaaaaa();");
}
TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
More information about the cfe-commits
mailing list