r236382 - clang-format: [JS] Fix templated parameter default values.
Daniel Jasper
djasper at google.com
Sat May 2 00:54:59 PDT 2015
Author: djasper
Date: Sat May 2 02:54:58 2015
New Revision: 236382
URL: http://llvm.org/viewvc/llvm-project?rev=236382&view=rev
Log:
clang-format: [JS] Fix templated parameter default values.
Parameters can have templated types and default values (= ...), which is
another location in which a template closer should be followed by
whitespace.
Patch by Martin Probst, thank you.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=236382&r1=236381&r2=236382&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Sat May 2 02:54:58 2015
@@ -1804,7 +1804,7 @@ bool TokenAnnotator::spaceRequiredBefore
Line.First->isOneOf(Keywords.kw_import, tok::kw_export))
return false;
if (Left.is(TT_TemplateCloser) &&
- !Right.isOneOf(tok::l_brace, tok::comma, tok::l_square,
+ !Right.isOneOf(tok::equal, tok::l_brace, tok::comma, tok::l_square,
Keywords.kw_implements, Keywords.kw_extends))
// Type assertions ('<type>expr') are not followed by whitespace. Other
// locations that should have whitespace following are identified by the
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=236382&r1=236381&r2=236382&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Sat May 2 02:54:58 2015
@@ -687,6 +687,8 @@ TEST_F(FormatTestJS, TypeArguments) {
verifyFormat("foo<Y>(a);");
verifyFormat("var x: X<Y>[];");
verifyFormat("class C extends D<E> implements F<G>, H<I> {}");
+ verifyFormat("function f(a: List<any> = null) {\n}");
+ verifyFormat("function f(): List<any> {\n}");
}
TEST_F(FormatTestJS, OptionalTypes) {
More information about the cfe-commits
mailing list