diff options
| author | Martin Probst <martin@probst.io> | 2016-05-29 14:41:07 +0000 | 
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2016-05-29 14:41:07 +0000 | 
| commit | 409697ecb962d025ae06b18885ea3aa59e48f343 (patch) | |
| tree | 42fcd4cb21b44a3f9d36c826ee7da05ba28e95a8 /clang/lib | |
| parent | 1244ecbbd2072aa13f2bde79c00130486d9e7c78 (diff) | |
| download | bcm5719-llvm-409697ecb962d025ae06b18885ea3aa59e48f343.tar.gz bcm5719-llvm-409697ecb962d025ae06b18885ea3aa59e48f343.zip | |
clang-format: [JS] fix async parsing.
Summary:
Only treat the sequence `async function` as the start of a function expression,
as opposed to every occurrence of the token `async` (whoops).
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D20737
llvm-svn: 271184
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 13 | 
1 files changed, 9 insertions, 4 deletions
| diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index e14b2b44e8e..194a40e63fa 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1013,7 +1013,9 @@ void UnwrappedLineParser::parseStructuralElement() {        // Parse function literal unless 'function' is the first token in a line        // in which case this should be treated as a free-standing function.        if (Style.Language == FormatStyle::LK_JavaScript && -          FormatTok->isOneOf(Keywords.kw_async, Keywords.kw_function) && +          (FormatTok->is(Keywords.kw_function) || +           FormatTok->startsSequence(Keywords.kw_async, +                                     Keywords.kw_function)) &&            Line->Tokens.size() > 0) {          tryToParseJSFunction();          break; @@ -1200,7 +1202,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {  }  void UnwrappedLineParser::tryToParseJSFunction() { -  assert(FormatTok->isOneOf(Keywords.kw_async, Keywords.kw_function)); +  assert(FormatTok->is(Keywords.kw_function) || +         FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function));    if (FormatTok->is(Keywords.kw_async))      nextToken();    // Consume "function". @@ -1254,7 +1257,8 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons) {    // replace this by using parseAssigmentExpression() inside.    do {      if (Style.Language == FormatStyle::LK_JavaScript) { -      if (FormatTok->isOneOf(Keywords.kw_async, Keywords.kw_function)) { +      if (FormatTok->is(Keywords.kw_function) || +          FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function)) {          tryToParseJSFunction();          continue;        } @@ -1352,7 +1356,8 @@ void UnwrappedLineParser::parseParens() {        break;      case tok::identifier:        if (Style.Language == FormatStyle::LK_JavaScript && -          FormatTok->isOneOf(Keywords.kw_async, Keywords.kw_function)) +          (FormatTok->is(Keywords.kw_function) || +           FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function)))          tryToParseJSFunction();        else          nextToken(); | 

