From: Daniel Jasper Date: Thu, 26 Feb 2015 11:30:50 +0000 (+0000) Subject: clang-format: Fix space of arrays of pointers to templated types. X-Git-Tag: llvmorg-3.7.0-rc1~10789 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=beaa322c36e3cc00652bac081f91feaad29b80f3;p=platform%2Fupstream%2Fllvm.git clang-format: Fix space of arrays of pointers to templated types. Before: vector(*foo_)[6]; After: vector (*foo_)[6]; llvm-svn: 230625 --- diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index e233052..fa086a9 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1838,7 +1838,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) || Left.isOneOf(TT_BinaryOperator, TT_ConditionalExpr)) return true; - if (Left.is(TT_TemplateCloser) && Right.is(tok::l_paren)) + if (Left.is(TT_TemplateCloser) && Right.is(tok::l_paren) && + Right.isNot(TT_FunctionTypeLParen)) return Style.SpaceBeforeParens == FormatStyle::SBPO_Always; if (Right.is(TT_TemplateOpener) && Left.is(tok::r_paren) && Left.MatchingParen && Left.MatchingParen->is(TT_OverloadedOperatorLParen)) diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 5bf4d3c..cc27969 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5606,6 +5606,11 @@ TEST_F(FormatTest, FormatsFunctionTypes) { verifyFormat("void f() { function(*some_pointer_var)[0] = 10; }"); } +TEST_F(FormatTest, FormatsPointersToArrayTypes) { + verifyFormat("A (*foo_)[6];"); + verifyFormat("vector (*foo_)[6];"); +} + TEST_F(FormatTest, BreaksLongVariableDeclarations) { verifyFormat("LoooooooooooooooooooooooooooooooooooooooongType\n" " LoooooooooooooooooooooooooooooooooooooooongVariable;");