summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2016-06-09 22:49:04 +0000
committerMartin Probst <martin@probst.io>2016-06-09 22:49:04 +0000
commit2ec2324f3c70abd722eced1df41d7257143164ac (patch)
treeca581ab1828d429f7c4e7f6d351a449786491f98 /clang/lib/Format
parent4acea0aa2276111142e43e601b88f68ed8107570 (diff)
downloadbcm5719-llvm-2ec2324f3c70abd722eced1df41d7257143164ac.tar.gz
bcm5719-llvm-2ec2324f3c70abd722eced1df41d7257143164ac.zip
clang-format: [JS] recognized named functions in AnnotatingParser.
Summary: This also fixes union type formatting in function parameter types. Before: function x(path: number| string) {} After: function x(path: number|string) {} Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D21206 llvm-svn: 272330
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 2a5fe94e009..b469cfad2bb 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -142,7 +142,10 @@ private:
// static_assert, if and while usually contain expressions.
Contexts.back().IsExpression = true;
} else if (Style.Language == FormatStyle::LK_JavaScript && Left->Previous &&
- Left->Previous->is(Keywords.kw_function)) {
+ (Left->Previous->is(Keywords.kw_function) ||
+ (Left->Previous->endsSequence(tok::identifier,
+ Keywords.kw_function)))) {
+ // function(...) or function f(...)
Contexts.back().IsExpression = false;
} else if (Left->Previous && Left->Previous->is(tok::r_square) &&
Left->Previous->MatchingParen &&
OpenPOWER on IntegriCloud