r222283 - clang-format: Fix space between generic type parameter and square
Daniel Jasper
djasper at google.com
Tue Nov 18 15:48:01 PST 2014
Author: djasper
Date: Tue Nov 18 17:48:01 2014
New Revision: 222283
URL: http://llvm.org/viewvc/llvm-project?rev=222283&view=rev
Log:
clang-format: Fix space between generic type parameter and square
bracket
Before:
public Foo<X, Y> [] foos;
After:
public Foo<X, Y>[] foos;
Patch by Harry Terkelsen. Thank you!
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJava.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=222283&r1=222282&r2=222283&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov 18 17:48:01 2014
@@ -1677,6 +1677,8 @@ bool TokenAnnotator::spaceRequiredBetwee
Left.MatchingParen->Previous->is(tok::period))
// A.<B>DoSomething();
return false;
+ if (Left.Type == TT_TemplateCloser && Right.is(tok::l_square))
+ return false;
return true;
}
Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJava.cpp?rev=222283&r1=222282&r2=222283&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Nov 18 17:48:01 2014
@@ -217,6 +217,9 @@ TEST_F(FormatTestJava, Generics) {
verifyFormat("public static <R> ArrayList<R> get() {\n}");
verifyFormat("<T extends B> T getInstance(Class<T> type);");
verifyFormat("Function<F, ? extends T> function;");
+
+ verifyFormat("private Foo<X, Y>[] foos;");
+ verifyFormat("Foo<X, Y>[] foos = this.foos;");
}
TEST_F(FormatTestJava, StringConcatenation) {
More information about the cfe-commits
mailing list