diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-04-27 06:18:01 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-04-27 06:18:01 +0000 |
commit | 5ecdd78408a1c6f4be506d94f776642570d27336 (patch) | |
tree | 90db5471e84192d54263ac2bb1de4c25e0016423 /lib/Parse/ParseStmt.cpp | |
parent | 4d53be4a470fc546b4c1e7618a11cf8bc7c00675 (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/ParseStmt.cpp')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 2ab2fcc69d..07cef5597b 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -146,13 +146,15 @@ Retry: Tok.setKind(tok::annot_typename); setTypeAnnotation(Tok, Classification.getType()); Tok.setAnnotationEndLoc(NameLoc); - Tok.setLocation(NameLoc); PP.AnnotateCachedTokens(Tok); break; case Sema::NC_Expression: - ConsumeToken(); // the identifier - return ParseExprStatement(attrs, Classification.getExpression()); + Tok.setKind(tok::annot_primary_expr); + setExprAnnotation(Tok, Classification.getExpression()); + Tok.setAnnotationEndLoc(NameLoc); + PP.AnnotateCachedTokens(Tok); + break; case Sema::NC_TypeTemplate: case Sema::NC_FunctionTemplate: { @@ -210,7 +212,7 @@ Retry: return StmtError(); } - return ParseExprStatement(attrs, ExprResult()); + return ParseExprStatement(attrs); } case tok::kw_case: // C99 6.8.1: labeled-statement @@ -288,14 +290,13 @@ Retry: } /// \brief Parse an expression statement. -StmtResult Parser::ParseExprStatement(ParsedAttributes &Attrs, - ExprResult Primary) { +StmtResult Parser::ParseExprStatement(ParsedAttributes &Attrs) { // If a case keyword is missing, this is where it should be inserted. Token OldToken = Tok; // FIXME: Use the attributes // expression[opt] ';' - ExprResult Expr(ParseExpression(Primary)); + ExprResult Expr(ParseExpression()); if (Expr.isInvalid()) { // If the expression is invalid, skip ahead to the next semicolon or '}'. // Not doing this opens us up to the possibility of infinite loops if |