diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Format')
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Format/TokenAnnotator.cpp | 10 | ||||
| -rw-r--r-- | contrib/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp | 18 | 
2 files changed, 17 insertions, 11 deletions
| diff --git a/contrib/llvm/tools/clang/lib/Format/TokenAnnotator.cpp b/contrib/llvm/tools/clang/lib/Format/TokenAnnotator.cpp index cf6373f45657..b5f7de280acd 100644 --- a/contrib/llvm/tools/clang/lib/Format/TokenAnnotator.cpp +++ b/contrib/llvm/tools/clang/lib/Format/TokenAnnotator.cpp @@ -1282,9 +1282,7 @@ private:        return TT_UnaryOperator;      const FormatToken *NextToken = Tok.getNextNonComment(); -    if (!NextToken || -        NextToken->isOneOf(tok::arrow, Keywords.kw_final, tok::equal, -                           Keywords.kw_override) || +    if (!NextToken || NextToken->isOneOf(tok::arrow, tok::equal) ||          (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))        return TT_PointerOrReference; @@ -2088,9 +2086,9 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,          !Line.IsMultiVariableDeclStmt)))      return true;    if (Left.is(TT_PointerOrReference)) -    return Right.Tok.isLiteral() || -           Right.isOneOf(TT_BlockComment, Keywords.kw_final, -                         Keywords.kw_override) || +    return Right.Tok.isLiteral() || Right.is(TT_BlockComment) || +           (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) && +            !Right.is(TT_StartOfName)) ||             (Right.is(tok::l_brace) && Right.BlockKind == BK_Block) ||             (!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,                             tok::l_paren) && diff --git a/contrib/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp b/contrib/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp index 370cf7afa330..8fc3b78aee01 100644 --- a/contrib/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp +++ b/contrib/llvm/tools/clang/lib/Format/UnwrappedLineParser.cpp @@ -737,7 +737,7 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {        return;    }    if (Next->is(tok::exclaim) && PreviousMustBeValue) -    addUnwrappedLine(); +    return addUnwrappedLine();    bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);    bool NextEndsTemplateExpr =        Next->is(TT_TemplateString) && Next->TokenText.startswith("}"); @@ -745,9 +745,10 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {        (PreviousMustBeValue ||         Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,                           tok::minusminus))) -    addUnwrappedLine(); -  if (PreviousMustBeValue && isJSDeclOrStmt(Keywords, Next)) -    addUnwrappedLine(); +    return addUnwrappedLine(); +  if ((PreviousMustBeValue || Previous->is(tok::r_brace)) && +      isJSDeclOrStmt(Keywords, Next)) +    return addUnwrappedLine();  }  void UnwrappedLineParser::parseStructuralElement() { @@ -1974,7 +1975,14 @@ void UnwrappedLineParser::parseJavaScriptEs6ImportExport() {        !FormatTok->isStringLiteral())      return; -  while (!eof() && FormatTok->isNot(tok::semi)) { +  while (!eof()) { +    if (FormatTok->is(tok::semi)) +      return; +    if (Line->Tokens.size() == 0) { +      // Common issue: Automatic Semicolon Insertion wrapped the line, so the +      // import statement should terminate. +      return; +    }      if (FormatTok->is(tok::l_brace)) {        FormatTok->BlockKind = BK_Block;        parseBracedList(); | 
