From 71646ec206721c32cb10cd6f66c10a3709c54be0 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Wed, 30 Jul 2014 12:14:10 +0000 Subject: [PATCH] clang-format: Understand 'typename' in placement new. Before: new (aaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); After: new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa)) typename aaaaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 214300 --- clang/lib/Format/TokenAnnotator.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 269e2fc..6f77ae3 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1811,7 +1811,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, 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)); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index c942ae9..420129f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -4714,6 +4714,8 @@ TEST_F(FormatTest, UnderstandsNewAndDelete) { " delete a;\n" " delete (A *)a;\n" "}"); + verifyFormat("new (aaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa))\n" + " typename aaaaaaaaaaaaaaaaaaaaaaaa();"); } TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { -- 2.7.4