From: Daniel Jasper Date: Tue, 18 Nov 2014 23:48:01 +0000 (+0000) Subject: clang-format: Fix space between generic type parameter and square X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ba90485a05f5e6431bca36ba1c64c3cbce80def;p=clang clang-format: Fix space between generic type parameter and square bracket Before: public Foo [] foos; After: public Foo[] foos; Patch by Harry Terkelsen. Thank you! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@222283 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index dfd880aa99..fdb1179b57 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1677,6 +1677,8 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line, Left.MatchingParen->Previous->is(tok::period)) // A.DoSomething(); return false; + if (Left.Type == TT_TemplateCloser && Right.is(tok::l_square)) + return false; return true; } diff --git a/unittests/Format/FormatTestJava.cpp b/unittests/Format/FormatTestJava.cpp index eecac0f3fc..d60ab965b9 100644 --- a/unittests/Format/FormatTestJava.cpp +++ b/unittests/Format/FormatTestJava.cpp @@ -217,6 +217,9 @@ TEST_F(FormatTestJava, Generics) { verifyFormat("public static ArrayList get() {\n}"); verifyFormat(" T getInstance(Class type);"); verifyFormat("Function function;"); + + verifyFormat("private Foo[] foos;"); + verifyFormat("Foo[] foos = this.foos;"); } TEST_F(FormatTestJava, StringConcatenation) {