From: Anders Carlsson Date: Sun, 17 May 2009 21:11:30 +0000 (+0000) Subject: Make ActOnExprStmt take a FullExprArg. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b1d283fe879fb11d7ce7a69feecf66e77b0eaf3;p=clang Make ActOnExprStmt take a FullExprArg. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71989 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 6d4e2b753d..cd1945704f 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -460,8 +460,8 @@ public: return StmtEmpty(); } - virtual OwningStmtResult ActOnExprStmt(ExprArg Expr) { - return OwningStmtResult(*this, Expr.release()); + virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) { + return OwningStmtResult(*this, Expr->release()); } /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension, diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 3133a8f42c..19ab835707 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -594,6 +594,9 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, // effects (e.g. a placement new with an uninitialized POD). case CXXDeleteExprClass: return false; + case CXXExprWithTemporariesClass: + return cast(this) + ->getSubExpr()->isUnusedResultAWarning(Loc, R1, R2); } } diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index 6c42f429cc..e1d0bb6e13 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1408,7 +1408,7 @@ Parser::OwningStmtResult Parser::ParseObjCAtStatement(SourceLocation AtLoc) { } // Otherwise, eat the semicolon. ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr); - return Actions.ActOnExprStmt(move(Res)); + return Actions.ActOnExprStmt(Actions.FullExpr(Res)); } Parser::OwningExprResult Parser::ParseObjCAtExpression(SourceLocation AtLoc) { diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 16b7a9f07f..cf4e2f44bc 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -121,7 +121,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) { } // Otherwise, eat the semicolon. ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr); - return Actions.ActOnExprStmt(move(Expr)); + return Actions.ActOnExprStmt(Actions.FullExpr(Expr)); } case tok::kw_case: // C99 6.8.1: labeled-statement @@ -457,7 +457,7 @@ Parser::OwningStmtResult Parser::ParseCompoundStatementBody(bool isStmtExpr) { // Eat the semicolon at the end of stmt and convert the expr into a // statement. ExpectAndConsume(tok::semi, diag::err_expected_semi_after_expr); - R = Actions.ActOnExprStmt(move(Res)); + R = Actions.ActOnExprStmt(Actions.FullExpr(Res)); } } @@ -929,7 +929,7 @@ Parser::OwningStmtResult Parser::ParseForStatement() { // Turn the expression into a stmt. if (!Value.isInvalid()) - FirstPart = Actions.ActOnExprStmt(move(Value)); + FirstPart = Actions.ActOnExprStmt(Actions.FullExpr(Value)); if (Tok.is(tok::semi)) { ConsumeToken(); diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index eb723bb080..9c27745498 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1155,7 +1155,7 @@ public: //===--------------------------------------------------------------------===// // Statement Parsing Callbacks: SemaStmt.cpp. public: - virtual OwningStmtResult ActOnExprStmt(ExprArg Expr); + virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr); virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc); virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 5c04c2491f..155b51048a 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -21,8 +21,8 @@ #include "clang/Basic/TargetInfo.h" using namespace clang; -Sema::OwningStmtResult Sema::ActOnExprStmt(ExprArg expr) { - Expr *E = expr.takeAs(); +Sema::OwningStmtResult Sema::ActOnExprStmt(FullExprArg expr) { + Expr *E = expr->takeAs(); assert(E && "ActOnExprStmt(): missing expression"); // C99 6.8.3p2: The expression in an expression statement is evaluated as a diff --git a/tools/clang-cc/PrintParserCallbacks.cpp b/tools/clang-cc/PrintParserCallbacks.cpp index 4ee48f072a..73a653d7d8 100644 --- a/tools/clang-cc/PrintParserCallbacks.cpp +++ b/tools/clang-cc/PrintParserCallbacks.cpp @@ -266,9 +266,9 @@ namespace { return StmtEmpty(); } - virtual OwningStmtResult ActOnExprStmt(ExprArg Expr) { + virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr) { llvm::cout << __FUNCTION__ << "\n"; - return OwningStmtResult(*this, Expr.release()); + return OwningStmtResult(*this, Expr->release()); } /// ActOnCaseStmt - Note that this handles the GNU 'case 1 ... 4' extension,