From 7f537c18c7029e73f0bd555be3782c066e7e2c1e Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 17 May 2009 21:22:26 +0000 Subject: [PATCH] Make ActOnWhileStmt take a FullExprArg for the condition expr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71990 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Parse/Action.h | 4 ++-- lib/Parse/ParseStmt.cpp | 2 +- lib/Sema/Sema.h | 4 ++-- lib/Sema/SemaStmt.cpp | 9 +++++---- lib/Sema/SemaTemplateInstantiateStmt.cpp | 2 +- tools/clang-cc/PrintParserCallbacks.cpp | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index cd1945704f..4d188b53fc 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -506,8 +506,8 @@ public: return StmtEmpty(); } - virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond, - StmtArg Body) { + virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, + FullExprArg Cond, StmtArg Body) { return StmtEmpty(); } virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index cf4e2f44bc..1bcfed7e20 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -777,7 +777,7 @@ Parser::OwningStmtResult Parser::ParseWhileStatement() { if (Cond.isInvalid() || Body.isInvalid()) return StmtError(); - return Actions.ActOnWhileStmt(WhileLoc, move(Cond), move(Body)); + return Actions.ActOnWhileStmt(WhileLoc, Actions.FullExpr(Cond), move(Body)); } /// ParseDoStatement diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 9c27745498..a5f50a80af 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -1182,8 +1182,8 @@ public: virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond); virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch, StmtArg Body); - virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond, - StmtArg Body); + virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, + FullExprArg Cond, StmtArg Body); virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, SourceLocation WhileLoc, ExprArg Cond); diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 155b51048a..ebaa99fa98 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -542,13 +542,14 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, StmtArg Switch, } Action::OwningStmtResult -Sema::ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond, StmtArg Body) { - Expr *condExpr = Cond.takeAs(); +Sema::ActOnWhileStmt(SourceLocation WhileLoc, FullExprArg Cond, StmtArg Body) { + ExprArg CondArg(Cond.release()); + Expr *condExpr = CondArg.takeAs(); assert(condExpr && "ActOnWhileStmt(): missing expression"); if (!condExpr->isTypeDependent()) { DefaultFunctionArrayConversion(condExpr); - Cond = condExpr; + CondArg = condExpr; QualType condType = condExpr->getType(); if (getLangOptions().CPlusPlus) { @@ -560,7 +561,7 @@ Sema::ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond, StmtArg Body) { << condType << condExpr->getSourceRange()); } - Cond.release(); + CondArg.release(); return Owned(new (Context) WhileStmt(condExpr, Body.takeAs(), WhileLoc)); } diff --git a/lib/Sema/SemaTemplateInstantiateStmt.cpp b/lib/Sema/SemaTemplateInstantiateStmt.cpp index 8dcdce2712..938e58b8fd 100644 --- a/lib/Sema/SemaTemplateInstantiateStmt.cpp +++ b/lib/Sema/SemaTemplateInstantiateStmt.cpp @@ -267,7 +267,7 @@ Sema::OwningStmtResult TemplateStmtInstantiator::VisitWhileStmt(WhileStmt *S) { if (Body.isInvalid()) return SemaRef.StmtError(); - return SemaRef.ActOnWhileStmt(S->getWhileLoc(), move(Cond), move(Body)); + return SemaRef.ActOnWhileStmt(S->getWhileLoc(), FullExpr(Cond), move(Body)); } Sema::OwningStmtResult TemplateStmtInstantiator::VisitDoStmt(DoStmt *S) { diff --git a/tools/clang-cc/PrintParserCallbacks.cpp b/tools/clang-cc/PrintParserCallbacks.cpp index 73a653d7d8..f99ee277d1 100644 --- a/tools/clang-cc/PrintParserCallbacks.cpp +++ b/tools/clang-cc/PrintParserCallbacks.cpp @@ -317,7 +317,7 @@ namespace { } virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, - ExprArg Cond, StmtArg Body) { + FullExprArg Cond, StmtArg Body) { llvm::cout << __FUNCTION__ << "\n"; return StmtEmpty(); } -- 2.40.0