diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-01-15 15:39:40 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-01-15 15:39:40 +0000 |
commit | ee791dde723a2089c681d2ab6a9d4f96379d5f49 (patch) | |
tree | a6082d4d1d1e9ddaea09a6a04bb4a47da95d642d /lib/Parse/ParseExpr.cpp | |
parent | abe15e553e58165e7692c0d0842865c488ed7b45 (diff) | |
download | src-ee791dde723a2089c681d2ab6a9d4f96379d5f49.tar.gz src-ee791dde723a2089c681d2ab6a9d4f96379d5f49.zip |
Notes
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index bdbc67f782dc..669575c4f030 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -200,11 +200,6 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind, /// expression ',' assignment-expression /// Parser::OwningExprResult Parser::ParseExpression() { - if (Tok.is(tok::code_completion)) { - Actions.CodeCompleteOrdinaryName(CurScope); - ConsumeToken(); - } - OwningExprResult LHS(ParseAssignmentExpression()); if (LHS.isInvalid()) return move(LHS); @@ -248,6 +243,11 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) { /// ParseAssignmentExpression - Parse an expr that doesn't include commas. /// Parser::OwningExprResult Parser::ParseAssignmentExpression() { + if (Tok.is(tok::code_completion)) { + Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Expression); + ConsumeToken(); + } + if (Tok.is(tok::kw_throw)) return ParseThrowExpression(); @@ -616,9 +616,17 @@ Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression, // Turn a potentially qualified name into a annot_typename or // annot_cxxscope if it would be valid. This handles things like x::y, etc. if (getLang().CPlusPlus) { - // If TryAnnotateTypeOrScopeToken annotates the token, tail recurse. - if (TryAnnotateTypeOrScopeToken()) - return ParseCastExpression(isUnaryExpression, isAddressOfOperand); + // Avoid the unnecessary parse-time lookup in the common case + // where the syntax forbids a type. + const Token &Next = NextToken(); + if (Next.is(tok::coloncolon) || + (!ColonIsSacred && Next.is(tok::colon)) || + Next.is(tok::less) || + Next.is(tok::l_paren)) { + // If TryAnnotateTypeOrScopeToken annotates the token, tail recurse. + if (TryAnnotateTypeOrScopeToken()) + return ParseCastExpression(isUnaryExpression, isAddressOfOperand); + } } // Consume the identifier so that we can see if it is followed by a '(' or |