зеркало из https://github.com/microsoft/clang-1.git
Convert selected expression parsers to use smart pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60900 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
01f2ffacc4
Коммит
2f7ece7c77
|
@ -150,12 +150,6 @@ namespace clang
|
||||||
public:
|
public:
|
||||||
typedef ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID> DumbResult;
|
typedef ActionBase::ActionResult<DestroyerToUID<Destroyer>::UID> DumbResult;
|
||||||
|
|
||||||
// For convenience and compatibility.
|
|
||||||
ASTOwningResult(bool invalid = false)
|
|
||||||
: Actions(0), Node(0), Invalid(invalid) {}
|
|
||||||
// Same
|
|
||||||
ASTOwningResult(const DiagnosticBuilder &)
|
|
||||||
: Actions(0), Node(0), Invalid(true) {}
|
|
||||||
explicit ASTOwningResult(ActionBase &actions, bool invalid = false)
|
explicit ASTOwningResult(ActionBase &actions, bool invalid = false)
|
||||||
: Actions(&actions), Node(0), Invalid(invalid) {}
|
: Actions(&actions), Node(0), Invalid(invalid) {}
|
||||||
ASTOwningResult(ActionBase &actions, void *node)
|
ASTOwningResult(ActionBase &actions, void *node)
|
||||||
|
|
|
@ -98,6 +98,8 @@ public:
|
||||||
|
|
||||||
OwningExprResult ExprError() { return OwningExprResult(Actions, true); }
|
OwningExprResult ExprError() { return OwningExprResult(Actions, true); }
|
||||||
OwningStmtResult StmtError() { return OwningStmtResult(Actions, true); }
|
OwningStmtResult StmtError() { return OwningStmtResult(Actions, true); }
|
||||||
|
OwningExprResult ExprError(const DiagnosticBuilder &) { return ExprError(); }
|
||||||
|
OwningStmtResult StmtError(const DiagnosticBuilder &) { return StmtError(); }
|
||||||
|
|
||||||
// Parsing methods.
|
// Parsing methods.
|
||||||
|
|
||||||
|
@ -479,15 +481,16 @@ private:
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// C99 6.5: Expressions.
|
// C99 6.5: Expressions.
|
||||||
|
|
||||||
ExprResult ParseExpression();
|
OwningExprResult ParseExpression();
|
||||||
ExprResult ParseConstantExpression();
|
OwningExprResult ParseConstantExpression();
|
||||||
ExprResult ParseAssignmentExpression(); // Expr that doesn't include commas.
|
// Expr that doesn't include commas.
|
||||||
|
OwningExprResult ParseAssignmentExpression();
|
||||||
|
|
||||||
ExprResult ParseExpressionWithLeadingAt(SourceLocation AtLoc);
|
ExprResult ParseExpressionWithLeadingAt(SourceLocation AtLoc);
|
||||||
|
|
||||||
ExprResult ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec);
|
ExprResult ParseRHSOfBinaryExpression(ExprResult LHS, unsigned MinPrec);
|
||||||
ExprResult ParseCastExpression(bool isUnaryExpression);
|
OwningExprResult ParseCastExpression(bool isUnaryExpression);
|
||||||
ExprResult ParsePostfixExpressionSuffix(ExprResult LHS);
|
OwningExprResult ParsePostfixExpressionSuffix(OwningExprResult LHS);
|
||||||
ExprResult ParseSizeofAlignofExpression();
|
ExprResult ParseSizeofAlignofExpression();
|
||||||
ExprResult ParseBuiltinPrimaryExpression();
|
ExprResult ParseBuiltinPrimaryExpression();
|
||||||
|
|
||||||
|
@ -568,7 +571,7 @@ private:
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// C++ if/switch/while/for condition expression.
|
// C++ if/switch/while/for condition expression.
|
||||||
ExprResult ParseCXXCondition();
|
OwningExprResult ParseCXXCondition();
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// C++ types
|
// C++ types
|
||||||
|
@ -582,7 +585,7 @@ private:
|
||||||
/// '{' ...
|
/// '{' ...
|
||||||
ExprResult ParseInitializer() {
|
ExprResult ParseInitializer() {
|
||||||
if (Tok.isNot(tok::l_brace))
|
if (Tok.isNot(tok::l_brace))
|
||||||
return ParseAssignmentExpression();
|
return ParseAssignmentExpression().result();
|
||||||
return ParseBraceInitializer();
|
return ParseBraceInitializer();
|
||||||
}
|
}
|
||||||
ExprResult ParseBraceInitializer();
|
ExprResult ParseBraceInitializer();
|
||||||
|
|
|
@ -126,7 +126,7 @@ AttributeList *Parser::ParseAttributes() {
|
||||||
|
|
||||||
// now parse the non-empty comma separated list of expressions
|
// now parse the non-empty comma separated list of expressions
|
||||||
while (1) {
|
while (1) {
|
||||||
OwningExprResult ArgExpr(Actions, ParseAssignmentExpression());
|
OwningExprResult ArgExpr(ParseAssignmentExpression());
|
||||||
if (ArgExpr.isInvalid()) {
|
if (ArgExpr.isInvalid()) {
|
||||||
ArgExprsOk = false;
|
ArgExprsOk = false;
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
|
@ -158,7 +158,7 @@ AttributeList *Parser::ParseAttributes() {
|
||||||
|
|
||||||
// now parse the list of expressions
|
// now parse the list of expressions
|
||||||
while (1) {
|
while (1) {
|
||||||
OwningExprResult ArgExpr(Actions, ParseAssignmentExpression());
|
OwningExprResult ArgExpr(ParseAssignmentExpression());
|
||||||
if (ArgExpr.isInvalid()) {
|
if (ArgExpr.isInvalid()) {
|
||||||
ArgExprsOk = false;
|
ArgExprsOk = false;
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
|
@ -842,7 +842,7 @@ ParseStructDeclaration(DeclSpec &DS,
|
||||||
|
|
||||||
if (Tok.is(tok::colon)) {
|
if (Tok.is(tok::colon)) {
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
OwningExprResult Res(Actions, ParseConstantExpression());
|
OwningExprResult Res(ParseConstantExpression());
|
||||||
if (Res.isInvalid())
|
if (Res.isInvalid())
|
||||||
SkipUntil(tok::semi, true, true);
|
SkipUntil(tok::semi, true, true);
|
||||||
else
|
else
|
||||||
|
@ -1796,7 +1796,7 @@ void Parser::ParseFunctionDeclarator(SourceLocation LParenLoc, Declarator &D,
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
|
|
||||||
// Parse the default argument
|
// Parse the default argument
|
||||||
OwningExprResult DefArgResult(Actions, ParseAssignmentExpression());
|
OwningExprResult DefArgResult(ParseAssignmentExpression());
|
||||||
if (DefArgResult.isInvalid()) {
|
if (DefArgResult.isInvalid()) {
|
||||||
SkipUntil(tok::comma, tok::r_paren, true, true);
|
SkipUntil(tok::comma, tok::r_paren, true, true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1992,8 +1992,7 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OwningExprResult Result(Actions,
|
OwningExprResult Result(ParseCastExpression(true/*isUnaryExpression*/));
|
||||||
ParseCastExpression(true/*isUnaryExpression*/));
|
|
||||||
if (Result.isInvalid())
|
if (Result.isInvalid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -2025,7 +2024,7 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
|
||||||
if (DS.SetTypeSpecType(DeclSpec::TST_typeofType, StartLoc, PrevSpec, Ty))
|
if (DS.SetTypeSpecType(DeclSpec::TST_typeofType, StartLoc, PrevSpec, Ty))
|
||||||
Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
|
Diag(StartLoc, diag::err_invalid_decl_spec_combination) << PrevSpec;
|
||||||
} else { // we have an expression.
|
} else { // we have an expression.
|
||||||
OwningExprResult Result(Actions, ParseExpression());
|
OwningExprResult Result(ParseExpression());
|
||||||
|
|
||||||
if (Result.isInvalid() || Tok.isNot(tok::r_paren)) {
|
if (Result.isInvalid() || Tok.isNot(tok::r_paren)) {
|
||||||
MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
MatchRHSPunctuation(tok::r_paren, LParenLoc);
|
||||||
|
|
|
@ -169,14 +169,14 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind) {
|
||||||
/// assignment-expression
|
/// assignment-expression
|
||||||
/// expression ',' assignment-expression
|
/// expression ',' assignment-expression
|
||||||
///
|
///
|
||||||
Parser::ExprResult Parser::ParseExpression() {
|
Parser::OwningExprResult Parser::ParseExpression() {
|
||||||
if (Tok.is(tok::kw_throw))
|
if (Tok.is(tok::kw_throw))
|
||||||
return ParseThrowExpression();
|
return Owned(ParseThrowExpression());
|
||||||
|
|
||||||
OwningExprResult LHS(Actions, ParseCastExpression(false));
|
OwningExprResult LHS(ParseCastExpression(false));
|
||||||
if (LHS.isInvalid()) return LHS.result();
|
if (LHS.isInvalid()) return move(LHS);
|
||||||
|
|
||||||
return ParseRHSOfBinaryExpression(LHS.result(), prec::Comma);
|
return Owned(ParseRHSOfBinaryExpression(LHS.result(), prec::Comma));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This routine is called when the '@' is seen and consumed.
|
/// This routine is called when the '@' is seen and consumed.
|
||||||
|
@ -193,14 +193,14 @@ Parser::ExprResult Parser::ParseExpressionWithLeadingAt(SourceLocation AtLoc) {
|
||||||
|
|
||||||
/// ParseAssignmentExpression - Parse an expr that doesn't include commas.
|
/// ParseAssignmentExpression - Parse an expr that doesn't include commas.
|
||||||
///
|
///
|
||||||
Parser::ExprResult Parser::ParseAssignmentExpression() {
|
Parser::OwningExprResult Parser::ParseAssignmentExpression() {
|
||||||
if (Tok.is(tok::kw_throw))
|
if (Tok.is(tok::kw_throw))
|
||||||
return ParseThrowExpression();
|
return Owned(ParseThrowExpression());
|
||||||
|
|
||||||
OwningExprResult LHS(Actions, ParseCastExpression(false));
|
OwningExprResult LHS(ParseCastExpression(false));
|
||||||
if (LHS.isInvalid()) return LHS.result();
|
if (LHS.isInvalid()) return move(LHS);
|
||||||
|
|
||||||
return ParseRHSOfBinaryExpression(LHS.result(), prec::Assignment);
|
return Owned(ParseRHSOfBinaryExpression(LHS.result(), prec::Assignment));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParseAssignmentExprWithObjCMessageExprStart - Parse an assignment expression
|
/// ParseAssignmentExprWithObjCMessageExprStart - Parse an assignment expression
|
||||||
|
@ -220,17 +220,17 @@ Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc,
|
||||||
ReceiverName,
|
ReceiverName,
|
||||||
ReceiverExpr));
|
ReceiverExpr));
|
||||||
if (R.isInvalid()) return R.result();
|
if (R.isInvalid()) return R.result();
|
||||||
R = ParsePostfixExpressionSuffix(R.result());
|
R = ParsePostfixExpressionSuffix(move(R));
|
||||||
if (R.isInvalid()) return R.result();
|
if (R.isInvalid()) return R.result();
|
||||||
return ParseRHSOfBinaryExpression(R.result(), 2);
|
return ParseRHSOfBinaryExpression(R.result(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Parser::ExprResult Parser::ParseConstantExpression() {
|
Parser::OwningExprResult Parser::ParseConstantExpression() {
|
||||||
OwningExprResult LHS(Actions, ParseCastExpression(false));
|
OwningExprResult LHS(ParseCastExpression(false));
|
||||||
if (LHS.isInvalid()) return LHS.result();
|
if (LHS.isInvalid()) return move(LHS);
|
||||||
|
|
||||||
return ParseRHSOfBinaryExpression(LHS.result(), prec::Conditional);
|
return Owned(ParseRHSOfBinaryExpression(LHS.result(), prec::Conditional));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParseRHSOfBinaryExpression - Parse a binary expression that starts with
|
/// ParseRHSOfBinaryExpression - Parse a binary expression that starts with
|
||||||
|
@ -281,7 +281,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHSArg, unsigned MinPrec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse another leaf here for the RHS of the operator.
|
// Parse another leaf here for the RHS of the operator.
|
||||||
OwningExprResult RHS(Actions, ParseCastExpression(false));
|
OwningExprResult RHS(ParseCastExpression(false));
|
||||||
if (RHS.isInvalid())
|
if (RHS.isInvalid())
|
||||||
return RHS.result();
|
return RHS.result();
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHSArg, unsigned MinPrec) {
|
||||||
/// '::'[opt] 'delete' cast-expression
|
/// '::'[opt] 'delete' cast-expression
|
||||||
/// '::'[opt] 'delete' '[' ']' cast-expression
|
/// '::'[opt] 'delete' '[' ']' cast-expression
|
||||||
///
|
///
|
||||||
Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
Parser::OwningExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
if (getLang().CPlusPlus) {
|
if (getLang().CPlusPlus) {
|
||||||
// Annotate typenames and C++ scope specifiers.
|
// Annotate typenames and C++ scope specifiers.
|
||||||
// Used only in C++, where the typename can be considered as a functional
|
// Used only in C++, where the typename can be considered as a functional
|
||||||
|
@ -444,7 +444,7 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
SourceLocation LParenLoc = Tok.getLocation();
|
SourceLocation LParenLoc = Tok.getLocation();
|
||||||
SourceLocation RParenLoc;
|
SourceLocation RParenLoc;
|
||||||
Res = ParseParenExpression(ParenExprType, CastTy, RParenLoc);
|
Res = ParseParenExpression(ParenExprType, CastTy, RParenLoc);
|
||||||
if (Res.isInvalid()) return Res.result();
|
if (Res.isInvalid()) return move(Res);
|
||||||
|
|
||||||
switch (ParenExprType) {
|
switch (ParenExprType) {
|
||||||
case SimpleExpr: break; // Nothing else to do.
|
case SimpleExpr: break; // Nothing else to do.
|
||||||
|
@ -461,11 +461,11 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
if (!Res.isInvalid())
|
if (!Res.isInvalid())
|
||||||
Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc,
|
Res = Actions.ActOnCastExpr(LParenLoc, CastTy, RParenLoc,
|
||||||
Res.release());
|
Res.release());
|
||||||
return Res.result();
|
return move(Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// These can be followed by postfix-expr pieces.
|
// These can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
}
|
}
|
||||||
|
|
||||||
// primary-expression
|
// primary-expression
|
||||||
|
@ -477,11 +477,11 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
|
|
||||||
// These can be followed by postfix-expr pieces.
|
// These can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
|
|
||||||
case tok::kw_true:
|
case tok::kw_true:
|
||||||
case tok::kw_false:
|
case tok::kw_false:
|
||||||
return ParseCXXBoolLiteral();
|
return Owned(ParseCXXBoolLiteral());
|
||||||
|
|
||||||
case tok::identifier: { // primary-expression: identifier
|
case tok::identifier: { // primary-expression: identifier
|
||||||
// unqualified-id: identifier
|
// unqualified-id: identifier
|
||||||
|
@ -495,42 +495,43 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
SourceLocation L = ConsumeToken();
|
SourceLocation L = ConsumeToken();
|
||||||
Res = Actions.ActOnIdentifierExpr(CurScope, L, II, Tok.is(tok::l_paren));
|
Res = Actions.ActOnIdentifierExpr(CurScope, L, II, Tok.is(tok::l_paren));
|
||||||
// These can be followed by postfix-expr pieces.
|
// These can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
}
|
}
|
||||||
case tok::char_constant: // constant: character-constant
|
case tok::char_constant: // constant: character-constant
|
||||||
Res = Actions.ActOnCharacterConstant(Tok);
|
Res = Actions.ActOnCharacterConstant(Tok);
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
// These can be followed by postfix-expr pieces.
|
// These can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
case tok::kw___func__: // primary-expression: __func__ [C99 6.4.2.2]
|
case tok::kw___func__: // primary-expression: __func__ [C99 6.4.2.2]
|
||||||
case tok::kw___FUNCTION__: // primary-expression: __FUNCTION__ [GNU]
|
case tok::kw___FUNCTION__: // primary-expression: __FUNCTION__ [GNU]
|
||||||
case tok::kw___PRETTY_FUNCTION__: // primary-expression: __P..Y_F..N__ [GNU]
|
case tok::kw___PRETTY_FUNCTION__: // primary-expression: __P..Y_F..N__ [GNU]
|
||||||
Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
|
Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
// These can be followed by postfix-expr pieces.
|
// These can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
case tok::string_literal: // primary-expression: string-literal
|
case tok::string_literal: // primary-expression: string-literal
|
||||||
case tok::wide_string_literal:
|
case tok::wide_string_literal:
|
||||||
Res = ParseStringLiteralExpression();
|
Res = ParseStringLiteralExpression();
|
||||||
if (Res.isInvalid()) return Res.result();
|
if (Res.isInvalid()) return move(Res);
|
||||||
// This can be followed by postfix-expr pieces (e.g. "foo"[1]).
|
// This can be followed by postfix-expr pieces (e.g. "foo"[1]).
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
case tok::kw___builtin_va_arg:
|
case tok::kw___builtin_va_arg:
|
||||||
case tok::kw___builtin_offsetof:
|
case tok::kw___builtin_offsetof:
|
||||||
case tok::kw___builtin_choose_expr:
|
case tok::kw___builtin_choose_expr:
|
||||||
case tok::kw___builtin_overload:
|
case tok::kw___builtin_overload:
|
||||||
case tok::kw___builtin_types_compatible_p:
|
case tok::kw___builtin_types_compatible_p:
|
||||||
return ParseBuiltinPrimaryExpression();
|
return Owned(ParseBuiltinPrimaryExpression());
|
||||||
case tok::kw___null:
|
case tok::kw___null:
|
||||||
return Actions.ActOnGNUNullExpr(ConsumeToken());
|
return Owned(Actions.ActOnGNUNullExpr(ConsumeToken()));
|
||||||
break;
|
break;
|
||||||
case tok::plusplus: // unary-expression: '++' unary-expression
|
case tok::plusplus: // unary-expression: '++' unary-expression
|
||||||
case tok::minusminus: { // unary-expression: '--' unary-expression
|
case tok::minusminus: { // unary-expression: '--' unary-expression
|
||||||
SourceLocation SavedLoc = ConsumeToken();
|
SourceLocation SavedLoc = ConsumeToken();
|
||||||
Res = ParseCastExpression(true);
|
Res = ParseCastExpression(true);
|
||||||
if (!Res.isInvalid())
|
if (!Res.isInvalid())
|
||||||
Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
|
Res = Owned(Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind,
|
||||||
return Res.result();
|
Res.release()));
|
||||||
|
return move(Res);
|
||||||
}
|
}
|
||||||
case tok::amp: // unary-expression: '&' cast-expression
|
case tok::amp: // unary-expression: '&' cast-expression
|
||||||
case tok::star: // unary-expression: '*' cast-expression
|
case tok::star: // unary-expression: '*' cast-expression
|
||||||
|
@ -544,7 +545,7 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
Res = ParseCastExpression(false);
|
Res = ParseCastExpression(false);
|
||||||
if (!Res.isInvalid())
|
if (!Res.isInvalid())
|
||||||
Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
|
Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
|
||||||
return Res.result();
|
return move(Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
case tok::kw___extension__:{//unary-expression:'__extension__' cast-expr [GNU]
|
case tok::kw___extension__:{//unary-expression:'__extension__' cast-expr [GNU]
|
||||||
|
@ -554,7 +555,7 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
Res = ParseCastExpression(false);
|
Res = ParseCastExpression(false);
|
||||||
if (!Res.isInvalid())
|
if (!Res.isInvalid())
|
||||||
Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
|
Res = Actions.ActOnUnaryOp(CurScope, SavedLoc, SavedKind, Res.release());
|
||||||
return Res.result();
|
return move(Res);
|
||||||
}
|
}
|
||||||
case tok::kw_sizeof: // unary-expression: 'sizeof' unary-expression
|
case tok::kw_sizeof: // unary-expression: 'sizeof' unary-expression
|
||||||
// unary-expression: 'sizeof' '(' type-name ')'
|
// unary-expression: 'sizeof' '(' type-name ')'
|
||||||
|
@ -562,19 +563,17 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
case tok::kw___alignof: // unary-expression: '__alignof' unary-expression
|
case tok::kw___alignof: // unary-expression: '__alignof' unary-expression
|
||||||
// unary-expression: '__alignof' '(' type-name ')'
|
// unary-expression: '__alignof' '(' type-name ')'
|
||||||
// unary-expression: 'alignof' '(' type-id ')'
|
// unary-expression: 'alignof' '(' type-id ')'
|
||||||
return ParseSizeofAlignofExpression();
|
return Owned(ParseSizeofAlignofExpression());
|
||||||
case tok::ampamp: { // unary-expression: '&&' identifier
|
case tok::ampamp: { // unary-expression: '&&' identifier
|
||||||
SourceLocation AmpAmpLoc = ConsumeToken();
|
SourceLocation AmpAmpLoc = ConsumeToken();
|
||||||
if (Tok.isNot(tok::identifier)) {
|
if (Tok.isNot(tok::identifier))
|
||||||
Diag(Tok, diag::err_expected_ident);
|
return ExprError(Diag(Tok, diag::err_expected_ident));
|
||||||
return ExprResult(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
|
Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
|
||||||
Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(),
|
Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(),
|
||||||
Tok.getIdentifierInfo());
|
Tok.getIdentifierInfo());
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
return Res.result();
|
return move(Res);
|
||||||
}
|
}
|
||||||
case tok::kw_const_cast:
|
case tok::kw_const_cast:
|
||||||
case tok::kw_dynamic_cast:
|
case tok::kw_dynamic_cast:
|
||||||
|
@ -582,15 +581,15 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
case tok::kw_static_cast:
|
case tok::kw_static_cast:
|
||||||
Res = ParseCXXCasts();
|
Res = ParseCXXCasts();
|
||||||
// These can be followed by postfix-expr pieces.
|
// These can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
case tok::kw_typeid:
|
case tok::kw_typeid:
|
||||||
Res = ParseCXXTypeid();
|
Res = ParseCXXTypeid();
|
||||||
// This can be followed by postfix-expr pieces.
|
// This can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
case tok::kw_this:
|
case tok::kw_this:
|
||||||
Res = ParseCXXThis();
|
Res = ParseCXXThis();
|
||||||
// This can be followed by postfix-expr pieces.
|
// This can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
|
|
||||||
case tok::kw_char:
|
case tok::kw_char:
|
||||||
case tok::kw_wchar_t:
|
case tok::kw_wchar_t:
|
||||||
|
@ -613,52 +612,52 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
DeclSpec DS;
|
DeclSpec DS;
|
||||||
ParseCXXSimpleTypeSpecifier(DS);
|
ParseCXXSimpleTypeSpecifier(DS);
|
||||||
if (Tok.isNot(tok::l_paren))
|
if (Tok.isNot(tok::l_paren))
|
||||||
return Diag(Tok, diag::err_expected_lparen_after_type)
|
return ExprError(Diag(Tok, diag::err_expected_lparen_after_type)
|
||||||
<< DS.getSourceRange();
|
<< DS.getSourceRange());
|
||||||
|
|
||||||
Res = ParseCXXTypeConstructExpression(DS);
|
Res = ParseCXXTypeConstructExpression(DS);
|
||||||
// This can be followed by postfix-expr pieces.
|
// This can be followed by postfix-expr pieces.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
}
|
}
|
||||||
|
|
||||||
case tok::annot_cxxscope: // [C++] id-expression: qualified-id
|
case tok::annot_cxxscope: // [C++] id-expression: qualified-id
|
||||||
case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id
|
case tok::kw_operator: // [C++] id-expression: operator/conversion-function-id
|
||||||
// template-id
|
// template-id
|
||||||
Res = ParseCXXIdExpression();
|
Res = ParseCXXIdExpression();
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res));
|
||||||
|
|
||||||
case tok::coloncolon: // [C++] new-expression or [C++] delete-expression
|
case tok::coloncolon: // [C++] new-expression or [C++] delete-expression
|
||||||
// If the next token is neither 'new' nor 'delete', the :: would have been
|
// If the next token is neither 'new' nor 'delete', the :: would have been
|
||||||
// parsed as a scope specifier already.
|
// parsed as a scope specifier already.
|
||||||
if (NextToken().is(tok::kw_new))
|
if (NextToken().is(tok::kw_new))
|
||||||
return ParseCXXNewExpression();
|
return Owned(ParseCXXNewExpression());
|
||||||
else
|
else
|
||||||
return ParseCXXDeleteExpression();
|
return Owned(ParseCXXDeleteExpression());
|
||||||
|
|
||||||
case tok::kw_new: // [C++] new-expression
|
case tok::kw_new: // [C++] new-expression
|
||||||
return ParseCXXNewExpression();
|
return Owned(ParseCXXNewExpression());
|
||||||
|
|
||||||
case tok::kw_delete: // [C++] delete-expression
|
case tok::kw_delete: // [C++] delete-expression
|
||||||
return ParseCXXDeleteExpression();
|
return Owned(ParseCXXDeleteExpression());
|
||||||
|
|
||||||
case tok::at: {
|
case tok::at: {
|
||||||
SourceLocation AtLoc = ConsumeToken();
|
SourceLocation AtLoc = ConsumeToken();
|
||||||
return ParseObjCAtExpression(AtLoc);
|
return Owned(ParseObjCAtExpression(AtLoc));
|
||||||
}
|
}
|
||||||
case tok::l_square:
|
case tok::l_square:
|
||||||
// These can be followed by postfix-expr pieces.
|
// These can be followed by postfix-expr pieces.
|
||||||
if (getLang().ObjC1)
|
if (getLang().ObjC1)
|
||||||
return ParsePostfixExpressionSuffix(ParseObjCMessageExpression());
|
return ParsePostfixExpressionSuffix(Owned(ParseObjCMessageExpression()));
|
||||||
// FALL THROUGH.
|
// FALL THROUGH.
|
||||||
case tok::caret:
|
case tok::caret:
|
||||||
if (getLang().Blocks)
|
if (getLang().Blocks)
|
||||||
return ParsePostfixExpressionSuffix(ParseBlockLiteralExpression());
|
return ParsePostfixExpressionSuffix(Owned(ParseBlockLiteralExpression()));
|
||||||
Diag(Tok, diag::err_expected_expression);
|
Diag(Tok, diag::err_expected_expression);
|
||||||
return ExprResult(true);
|
return ExprError();
|
||||||
default:
|
default:
|
||||||
UnhandledToken:
|
UnhandledToken:
|
||||||
Diag(Tok, diag::err_expected_expression);
|
Diag(Tok, diag::err_expected_expression);
|
||||||
return ExprResult(true);
|
return ExprError();
|
||||||
}
|
}
|
||||||
|
|
||||||
// unreachable.
|
// unreachable.
|
||||||
|
@ -683,18 +682,18 @@ Parser::ExprResult Parser::ParseCastExpression(bool isUnaryExpression) {
|
||||||
/// argument-expression
|
/// argument-expression
|
||||||
/// argument-expression-list ',' assignment-expression
|
/// argument-expression-list ',' assignment-expression
|
||||||
///
|
///
|
||||||
Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHSArg) {
|
Parser::OwningExprResult
|
||||||
OwningExprResult LHS(Actions, LHSArg);
|
Parser::ParsePostfixExpressionSuffix(OwningExprResult LHS) {
|
||||||
// Now that the primary-expression piece of the postfix-expression has been
|
// Now that the primary-expression piece of the postfix-expression has been
|
||||||
// parsed, see if there are any postfix-expression pieces here.
|
// parsed, see if there are any postfix-expression pieces here.
|
||||||
SourceLocation Loc;
|
SourceLocation Loc;
|
||||||
while (1) {
|
while (1) {
|
||||||
switch (Tok.getKind()) {
|
switch (Tok.getKind()) {
|
||||||
default: // Not a postfix-expression suffix.
|
default: // Not a postfix-expression suffix.
|
||||||
return LHS.result();
|
return move(LHS);
|
||||||
case tok::l_square: { // postfix-expression: p-e '[' expression ']'
|
case tok::l_square: { // postfix-expression: p-e '[' expression ']'
|
||||||
Loc = ConsumeBracket();
|
Loc = ConsumeBracket();
|
||||||
OwningExprResult Idx(Actions, ParseExpression());
|
OwningExprResult Idx(ParseExpression());
|
||||||
|
|
||||||
SourceLocation RLoc = Tok.getLocation();
|
SourceLocation RLoc = Tok.getLocation();
|
||||||
|
|
||||||
|
@ -702,7 +701,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHSArg) {
|
||||||
LHS = Actions.ActOnArraySubscriptExpr(CurScope, LHS.release(), Loc,
|
LHS = Actions.ActOnArraySubscriptExpr(CurScope, LHS.release(), Loc,
|
||||||
Idx.release(), RLoc);
|
Idx.release(), RLoc);
|
||||||
} else
|
} else
|
||||||
LHS = ExprResult(true);
|
LHS = ExprError();
|
||||||
|
|
||||||
// Match the ']'.
|
// Match the ']'.
|
||||||
MatchRHSPunctuation(tok::r_square, Loc);
|
MatchRHSPunctuation(tok::r_square, Loc);
|
||||||
|
@ -718,7 +717,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHSArg) {
|
||||||
if (Tok.isNot(tok::r_paren)) {
|
if (Tok.isNot(tok::r_paren)) {
|
||||||
if (ParseExpressionList(ArgExprs, CommaLocs)) {
|
if (ParseExpressionList(ArgExprs, CommaLocs)) {
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
return ExprResult(true);
|
return ExprError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +741,7 @@ Parser::ExprResult Parser::ParsePostfixExpressionSuffix(ExprResult LHSArg) {
|
||||||
|
|
||||||
if (Tok.isNot(tok::identifier)) {
|
if (Tok.isNot(tok::identifier)) {
|
||||||
Diag(Tok, diag::err_expected_ident);
|
Diag(Tok, diag::err_expected_ident);
|
||||||
return ExprResult(true);
|
return ExprError();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!LHS.isInvalid()) {
|
if (!LHS.isInvalid()) {
|
||||||
|
@ -805,7 +804,7 @@ Parser::ExprResult Parser::ParseSizeofAlignofExpression() {
|
||||||
// If this is a parenthesized expression, it is the start of a
|
// If this is a parenthesized expression, it is the start of a
|
||||||
// unary-expression, but doesn't include any postfix pieces. Parse these
|
// unary-expression, but doesn't include any postfix pieces. Parse these
|
||||||
// now if present.
|
// now if present.
|
||||||
Operand = ParsePostfixExpressionSuffix(Operand.result());
|
Operand = ParsePostfixExpressionSuffix(move(Operand));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, the operand to the sizeof/alignof was an expresion.
|
// If we get here, the operand to the sizeof/alignof was an expresion.
|
||||||
|
@ -851,7 +850,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() {
|
||||||
switch (T) {
|
switch (T) {
|
||||||
default: assert(0 && "Not a builtin primary expression!");
|
default: assert(0 && "Not a builtin primary expression!");
|
||||||
case tok::kw___builtin_va_arg: {
|
case tok::kw___builtin_va_arg: {
|
||||||
OwningExprResult Expr(Actions, ParseAssignmentExpression());
|
OwningExprResult Expr(ParseAssignmentExpression());
|
||||||
if (Expr.isInvalid()) {
|
if (Expr.isInvalid()) {
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
return ExprResult(true);
|
return ExprResult(true);
|
||||||
|
@ -933,7 +932,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case tok::kw___builtin_choose_expr: {
|
case tok::kw___builtin_choose_expr: {
|
||||||
OwningExprResult Cond(Actions, ParseAssignmentExpression());
|
OwningExprResult Cond(ParseAssignmentExpression());
|
||||||
if (Cond.isInvalid()) {
|
if (Cond.isInvalid()) {
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
return Cond.result();
|
return Cond.result();
|
||||||
|
@ -941,7 +940,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() {
|
||||||
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
|
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
|
||||||
return ExprResult(true);
|
return ExprResult(true);
|
||||||
|
|
||||||
OwningExprResult Expr1(Actions, ParseAssignmentExpression());
|
OwningExprResult Expr1(ParseAssignmentExpression());
|
||||||
if (Expr1.isInvalid()) {
|
if (Expr1.isInvalid()) {
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
return Expr1.result();
|
return Expr1.result();
|
||||||
|
@ -949,7 +948,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() {
|
||||||
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
|
if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "",tok::r_paren))
|
||||||
return ExprResult(true);
|
return ExprResult(true);
|
||||||
|
|
||||||
OwningExprResult Expr2(Actions, ParseAssignmentExpression());
|
OwningExprResult Expr2(ParseAssignmentExpression());
|
||||||
if (Expr2.isInvalid()) {
|
if (Expr2.isInvalid()) {
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
return Expr2.result();
|
return Expr2.result();
|
||||||
|
@ -970,7 +969,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() {
|
||||||
// comma. If there is no comma, break and attempt to match r-paren.
|
// comma. If there is no comma, break and attempt to match r-paren.
|
||||||
if (Tok.isNot(tok::r_paren)) {
|
if (Tok.isNot(tok::r_paren)) {
|
||||||
while (1) {
|
while (1) {
|
||||||
OwningExprResult ArgExpr(Actions, ParseAssignmentExpression());
|
OwningExprResult ArgExpr(ParseAssignmentExpression());
|
||||||
if (ArgExpr.isInvalid()) {
|
if (ArgExpr.isInvalid()) {
|
||||||
SkipUntil(tok::r_paren);
|
SkipUntil(tok::r_paren);
|
||||||
return ExprResult(true);
|
return ExprResult(true);
|
||||||
|
@ -1012,7 +1011,7 @@ Parser::ExprResult Parser::ParseBuiltinPrimaryExpression() {
|
||||||
|
|
||||||
// These can be followed by postfix-expr pieces because they are
|
// These can be followed by postfix-expr pieces because they are
|
||||||
// primary-expressions.
|
// primary-expressions.
|
||||||
return ParsePostfixExpressionSuffix(Res.result());
|
return ParsePostfixExpressionSuffix(move(Res)).result();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParseParenExpression - This parses the unit that starts with a '(' token,
|
/// ParseParenExpression - This parses the unit that starts with a '(' token,
|
||||||
|
@ -1130,7 +1129,7 @@ Parser::ExprResult Parser::ParseStringLiteralExpression() {
|
||||||
///
|
///
|
||||||
bool Parser::ParseExpressionList(ExprListTy &Exprs, CommaLocsTy &CommaLocs) {
|
bool Parser::ParseExpressionList(ExprListTy &Exprs, CommaLocsTy &CommaLocs) {
|
||||||
while (1) {
|
while (1) {
|
||||||
OwningExprResult Expr(Actions, ParseAssignmentExpression());
|
OwningExprResult Expr(ParseAssignmentExpression());
|
||||||
if (Expr.isInvalid())
|
if (Expr.isInvalid())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ Parser::ExprResult Parser::ParseThrowExpression() {
|
||||||
return Actions.ActOnCXXThrow(ThrowLoc);
|
return Actions.ActOnCXXThrow(ThrowLoc);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
OwningExprResult Expr(Actions, ParseAssignmentExpression());
|
OwningExprResult Expr(ParseAssignmentExpression());
|
||||||
if (Expr.isInvalid()) return Expr.result();
|
if (Expr.isInvalid()) return Expr.result();
|
||||||
return Actions.ActOnCXXThrow(ThrowLoc, Expr.release());
|
return Actions.ActOnCXXThrow(ThrowLoc, Expr.release());
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ Parser::ExprResult Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {
|
||||||
/// [GNU] type-specifier-seq declarator simple-asm-expr[opt] attributes[opt]
|
/// [GNU] type-specifier-seq declarator simple-asm-expr[opt] attributes[opt]
|
||||||
/// '=' assignment-expression
|
/// '=' assignment-expression
|
||||||
///
|
///
|
||||||
Parser::ExprResult Parser::ParseCXXCondition() {
|
Parser::OwningExprResult Parser::ParseCXXCondition() {
|
||||||
if (!isCXXConditionDeclaration())
|
if (!isCXXConditionDeclaration())
|
||||||
return ParseExpression(); // expression
|
return ParseExpression(); // expression
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ Parser::ExprResult Parser::ParseCXXCondition() {
|
||||||
OwningExprResult AsmLabel(ParseSimpleAsm());
|
OwningExprResult AsmLabel(ParseSimpleAsm());
|
||||||
if (AsmLabel.isInvalid()) {
|
if (AsmLabel.isInvalid()) {
|
||||||
SkipUntil(tok::semi);
|
SkipUntil(tok::semi);
|
||||||
return true;
|
return ExprError();
|
||||||
}
|
}
|
||||||
DeclaratorInfo.setAsmLabel(AsmLabel.release());
|
DeclaratorInfo.setAsmLabel(AsmLabel.release());
|
||||||
}
|
}
|
||||||
|
@ -402,15 +402,15 @@ Parser::ExprResult Parser::ParseCXXCondition() {
|
||||||
|
|
||||||
// '=' assignment-expression
|
// '=' assignment-expression
|
||||||
if (Tok.isNot(tok::equal))
|
if (Tok.isNot(tok::equal))
|
||||||
return Diag(Tok, diag::err_expected_equal_after_declarator);
|
return ExprError(Diag(Tok, diag::err_expected_equal_after_declarator));
|
||||||
SourceLocation EqualLoc = ConsumeToken();
|
SourceLocation EqualLoc = ConsumeToken();
|
||||||
OwningExprResult AssignExpr(Actions, ParseAssignmentExpression());
|
OwningExprResult AssignExpr(ParseAssignmentExpression());
|
||||||
if (AssignExpr.isInvalid())
|
if (AssignExpr.isInvalid())
|
||||||
return true;
|
return ExprError();
|
||||||
|
|
||||||
return Actions.ActOnCXXConditionDeclarationExpr(CurScope, StartLoc,
|
return Owned(Actions.ActOnCXXConditionDeclarationExpr(CurScope, StartLoc,
|
||||||
DeclaratorInfo, EqualLoc,
|
DeclaratorInfo,EqualLoc,
|
||||||
AssignExpr.release());
|
AssignExpr.release()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
|
/// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
|
||||||
|
@ -776,8 +776,8 @@ void Parser::ParseDirectNewDeclarator(Declarator &D)
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (Tok.is(tok::l_square)) {
|
while (Tok.is(tok::l_square)) {
|
||||||
SourceLocation LLoc = ConsumeBracket();
|
SourceLocation LLoc = ConsumeBracket();
|
||||||
OwningExprResult Size(Actions, first ? ParseExpression()
|
OwningExprResult Size(first ? ParseExpression()
|
||||||
: ParseConstantExpression());
|
: ParseConstantExpression());
|
||||||
if (Size.isInvalid()) {
|
if (Size.isInvalid()) {
|
||||||
// Recover
|
// Recover
|
||||||
SkipUntil(tok::r_square);
|
SkipUntil(tok::r_square);
|
||||||
|
@ -851,7 +851,7 @@ Parser::ExprResult Parser::ParseCXXDeleteExpression()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OwningExprResult Operand(Actions, ParseCastExpression(false));
|
OwningExprResult Operand(ParseCastExpression(false));
|
||||||
if (Operand.isInvalid())
|
if (Operand.isInvalid())
|
||||||
return Operand.result();
|
return Operand.result();
|
||||||
|
|
||||||
|
|
|
@ -143,7 +143,7 @@ ParseInitializerWithPotentialDesignator(InitListDesignations &Designations,
|
||||||
// Note that we parse this as an assignment expression, not a constant
|
// Note that we parse this as an assignment expression, not a constant
|
||||||
// expression (allowing *=, =, etc) to handle the objc case. Sema needs
|
// expression (allowing *=, =, etc) to handle the objc case. Sema needs
|
||||||
// to validate that the expression is a constant.
|
// to validate that the expression is a constant.
|
||||||
OwningExprResult Idx(Actions, ParseAssignmentExpression());
|
OwningExprResult Idx(ParseAssignmentExpression());
|
||||||
if (Idx.isInvalid()) {
|
if (Idx.isInvalid()) {
|
||||||
SkipUntil(tok::r_square);
|
SkipUntil(tok::r_square);
|
||||||
return Idx.result();
|
return Idx.result();
|
||||||
|
@ -185,7 +185,7 @@ ParseInitializerWithPotentialDesignator(InitListDesignations &Designations,
|
||||||
Diag(Tok, diag::ext_gnu_array_range);
|
Diag(Tok, diag::ext_gnu_array_range);
|
||||||
ConsumeToken();
|
ConsumeToken();
|
||||||
|
|
||||||
OwningExprResult RHS(Actions, ParseConstantExpression());
|
OwningExprResult RHS(ParseConstantExpression());
|
||||||
if (RHS.isInvalid()) {
|
if (RHS.isInvalid()) {
|
||||||
SkipUntil(tok::r_square);
|
SkipUntil(tok::r_square);
|
||||||
return RHS.result();
|
return RHS.result();
|
||||||
|
|
|
@ -1199,7 +1199,7 @@ Parser::ParseObjCSynchronizedStmt(SourceLocation atLoc) {
|
||||||
return StmtError();
|
return StmtError();
|
||||||
}
|
}
|
||||||
ConsumeParen(); // '('
|
ConsumeParen(); // '('
|
||||||
OwningExprResult Res(Actions, ParseExpression());
|
OwningExprResult Res(ParseExpression());
|
||||||
if (Res.isInvalid()) {
|
if (Res.isInvalid()) {
|
||||||
SkipUntil(tok::semi);
|
SkipUntil(tok::semi);
|
||||||
return StmtError();
|
return StmtError();
|
||||||
|
@ -1397,18 +1397,22 @@ Parser::ExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) {
|
||||||
switch (Tok.getKind()) {
|
switch (Tok.getKind()) {
|
||||||
case tok::string_literal: // primary-expression: string-literal
|
case tok::string_literal: // primary-expression: string-literal
|
||||||
case tok::wide_string_literal:
|
case tok::wide_string_literal:
|
||||||
return ParsePostfixExpressionSuffix(ParseObjCStringLiteral(AtLoc));
|
return ParsePostfixExpressionSuffix(
|
||||||
|
Owned(ParseObjCStringLiteral(AtLoc))).result();
|
||||||
default:
|
default:
|
||||||
if (Tok.getIdentifierInfo() == 0)
|
if (Tok.getIdentifierInfo() == 0)
|
||||||
return Diag(AtLoc, diag::err_unexpected_at);
|
return Diag(AtLoc, diag::err_unexpected_at);
|
||||||
|
|
||||||
switch (Tok.getIdentifierInfo()->getObjCKeywordID()) {
|
switch (Tok.getIdentifierInfo()->getObjCKeywordID()) {
|
||||||
case tok::objc_encode:
|
case tok::objc_encode:
|
||||||
return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression(AtLoc));
|
return ParsePostfixExpressionSuffix(
|
||||||
|
Owned(ParseObjCEncodeExpression(AtLoc))).result();
|
||||||
case tok::objc_protocol:
|
case tok::objc_protocol:
|
||||||
return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression(AtLoc));
|
return ParsePostfixExpressionSuffix(
|
||||||
|
Owned(ParseObjCProtocolExpression(AtLoc))).result();
|
||||||
case tok::objc_selector:
|
case tok::objc_selector:
|
||||||
return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc));
|
return ParsePostfixExpressionSuffix(
|
||||||
|
Owned(ParseObjCSelectorExpression(AtLoc))).result();
|
||||||
default:
|
default:
|
||||||
return Diag(AtLoc, diag::err_unexpected_at);
|
return Diag(AtLoc, diag::err_unexpected_at);
|
||||||
}
|
}
|
||||||
|
@ -1433,7 +1437,7 @@ Parser::ExprResult Parser::ParseObjCMessageExpression() {
|
||||||
return ParseObjCMessageExpressionBody(LBracLoc, NameLoc, ReceiverName, 0);
|
return ParseObjCMessageExpressionBody(LBracLoc, NameLoc, ReceiverName, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
OwningExprResult Res(Actions, ParseExpression());
|
OwningExprResult Res(ParseExpression());
|
||||||
if (Res.isInvalid()) {
|
if (Res.isInvalid()) {
|
||||||
SkipUntil(tok::r_square);
|
SkipUntil(tok::r_square);
|
||||||
return Res.result();
|
return Res.result();
|
||||||
|
@ -1492,7 +1496,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
|
||||||
|
|
||||||
ConsumeToken(); // Eat the ':'.
|
ConsumeToken(); // Eat the ':'.
|
||||||
/// Parse the expression after ':'
|
/// Parse the expression after ':'
|
||||||
OwningExprResult Res(Actions, ParseAssignmentExpression());
|
OwningExprResult Res(ParseAssignmentExpression());
|
||||||
if (Res.isInvalid()) {
|
if (Res.isInvalid()) {
|
||||||
// We must manually skip to a ']', otherwise the expression skipper will
|
// We must manually skip to a ']', otherwise the expression skipper will
|
||||||
// stop at the ']' when it skips to the ';'. We want it to skip beyond
|
// stop at the ']' when it skips to the ';'. We want it to skip beyond
|
||||||
|
@ -1514,7 +1518,7 @@ Parser::ParseObjCMessageExpressionBody(SourceLocation LBracLoc,
|
||||||
while (Tok.is(tok::comma)) {
|
while (Tok.is(tok::comma)) {
|
||||||
ConsumeToken(); // Eat the ','.
|
ConsumeToken(); // Eat the ','.
|
||||||
/// Parse the expression after ','
|
/// Parse the expression after ','
|
||||||
OwningExprResult Res(Actions, ParseAssignmentExpression());
|
OwningExprResult Res(ParseAssignmentExpression());
|
||||||
if (Res.isInvalid()) {
|
if (Res.isInvalid()) {
|
||||||
// We must manually skip to a ']', otherwise the expression skipper will
|
// We must manually skip to a ']', otherwise the expression skipper will
|
||||||
// stop at the ']' when it skips to the ';'. We want it to skip beyond
|
// stop at the ']' when it skips to the ';'. We want it to skip beyond
|
||||||
|
|
|
@ -107,7 +107,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {
|
||||||
return StmtError();
|
return StmtError();
|
||||||
} else {
|
} else {
|
||||||
// expression[opt] ';'
|
// expression[opt] ';'
|
||||||
OwningExprResult Expr(Actions, ParseExpression());
|
OwningExprResult Expr(ParseExpression());
|
||||||
if (Expr.isInvalid()) {
|
if (Expr.isInvalid()) {
|
||||||
// If the expression is invalid, skip ahead to the next semicolon. Not
|
// If the expression is invalid, skip ahead to the next semicolon. Not
|
||||||
// doing this opens us up to the possibility of infinite loops if
|
// doing this opens us up to the possibility of infinite loops if
|
||||||
|
@ -226,7 +226,7 @@ Parser::OwningStmtResult Parser::ParseCaseStatement() {
|
||||||
assert(Tok.is(tok::kw_case) && "Not a case stmt!");
|
assert(Tok.is(tok::kw_case) && "Not a case stmt!");
|
||||||
SourceLocation CaseLoc = ConsumeToken(); // eat the 'case'.
|
SourceLocation CaseLoc = ConsumeToken(); // eat the 'case'.
|
||||||
|
|
||||||
OwningExprResult LHS(Actions, ParseConstantExpression());
|
OwningExprResult LHS(ParseConstantExpression());
|
||||||
if (LHS.isInvalid()) {
|
if (LHS.isInvalid()) {
|
||||||
SkipUntil(tok::colon);
|
SkipUntil(tok::colon);
|
||||||
return StmtError();
|
return StmtError();
|
||||||
|
@ -379,7 +379,7 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) {
|
||||||
} else {
|
} else {
|
||||||
// Otherwise this was a unary __extension__ marker. Parse the
|
// Otherwise this was a unary __extension__ marker. Parse the
|
||||||
// subexpression and add the __extension__ unary op.
|
// subexpression and add the __extension__ unary op.
|
||||||
OwningExprResult Res(Actions, ParseCastExpression(false));
|
OwningExprResult Res(ParseCastExpression(false));
|
||||||
|
|
||||||
if (Res.isInvalid()) {
|
if (Res.isInvalid()) {
|
||||||
SkipUntil(tok::semi);
|
SkipUntil(tok::semi);
|
||||||
|
@ -940,7 +940,7 @@ Parser::OwningStmtResult Parser::ParseGotoStatement() {
|
||||||
// GNU indirect goto extension.
|
// GNU indirect goto extension.
|
||||||
Diag(Tok, diag::ext_gnu_indirect_goto);
|
Diag(Tok, diag::ext_gnu_indirect_goto);
|
||||||
SourceLocation StarLoc = ConsumeToken();
|
SourceLocation StarLoc = ConsumeToken();
|
||||||
OwningExprResult R(Actions, ParseExpression());
|
OwningExprResult R(ParseExpression());
|
||||||
if (R.isInvalid()) { // Skip to the semicolon, but don't consume it.
|
if (R.isInvalid()) { // Skip to the semicolon, but don't consume it.
|
||||||
SkipUntil(tok::semi, false, true);
|
SkipUntil(tok::semi, false, true);
|
||||||
return StmtError();
|
return StmtError();
|
||||||
|
|
Загрузка…
Ссылка в новой задаче