aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-04-27 06:18:01 +0000
committerDouglas Gregor <dgregor@apple.com>2011-04-27 06:18:01 +0000
commit5ecdd78408a1c6f4be506d94f776642570d27336 (patch)
tree90db5471e84192d54263ac2bb1de4c25e0016423 /lib/Parse/ParseExpr.cpp
parent4d53be4a470fc546b4c1e7618a11cf8bc7c00675 (diff)
Introduce a new parser annotation token for primary expressions. When
ClassifyName() builds a primary expression, generate one of these annotation tokens rather than jumping into the parser. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130297 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r--lib/Parse/ParseExpr.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 12761e8d9f..c990c52e7b 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -174,11 +174,8 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind,
/// expression: [C99 6.5.17]
/// assignment-expression ...[opt]
/// expression ',' assignment-expression ...[opt]
-///
-/// \param Primary if non-empty, an already-parsed expression that will be used
-/// as the first primary expression.
-ExprResult Parser::ParseExpression(ExprResult Primary) {
- ExprResult LHS(ParseAssignmentExpression(Primary));
+ExprResult Parser::ParseExpression() {
+ ExprResult LHS(ParseAssignmentExpression());
return ParseRHSOfBinaryExpression(move(LHS), prec::Comma);
}
@@ -214,27 +211,16 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {
}
/// ParseAssignmentExpression - Parse an expr that doesn't include commas.
-///
-/// \param Primary if non-empty, an already-parsed expression that will be used
-/// as the first primary expression.
-ExprResult Parser::ParseAssignmentExpression(ExprResult Primary) {
+ExprResult Parser::ParseAssignmentExpression() {
if (Tok.is(tok::code_completion)) {
- if (Primary.isUsable())
- Actions.CodeCompletePostfixExpression(getCurScope(), Primary);
- else
- Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression);
+ Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Expression);
ConsumeCodeCompletionToken();
}
- if (!Primary.isUsable() && Tok.is(tok::kw_throw))
+ if (Tok.is(tok::kw_throw))
return ParseThrowExpression();
- ExprResult LHS;
- if (Primary.get() || Primary.isInvalid())
- LHS = ParsePostfixExpressionSuffix(Primary);
- else
- LHS = ParseCastExpression(false, false, ParsedType());
-
+ ExprResult LHS = ParseCastExpression(false, false, ParsedType());
return ParseRHSOfBinaryExpression(move(LHS), prec::Assignment);
}
@@ -628,6 +614,12 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
case tok::kw_nullptr:
return Actions.ActOnCXXNullPtrLiteral(ConsumeToken());
+ case tok::annot_primary_expr:
+ assert(Res.get() == 0 && "Stray primary-expression annotation?");
+ Res = getExprAnnotation(Tok);
+ ConsumeToken();
+ break;
+
case tok::identifier: { // primary-expression: identifier
// unqualified-id: identifier
// constant: enumeration-constant