aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-05-17 18:26:53 +0000
committerAnders Carlsson <andersca@mac.com>2009-05-17 18:26:53 +0000
commita99fad8ff134273fe85f2970c7d89133d1218900 (patch)
tree4d25d0300e3251287762c273b44817068f4c7c38 /lib/Sema
parent0e650017acdbbeb0c590e77bbea88c200ea1caef (diff)
Add the FullExprArg wrapper and use it for if statement conditions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71982 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r--lib/Sema/Sema.h6
-rw-r--r--lib/Sema/SemaStmt.cpp10
-rw-r--r--lib/Sema/SemaTemplateInstantiateStmt.cpp6
3 files changed, 14 insertions, 8 deletions
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 9a12dfd971..c4890499a6 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -1172,9 +1172,9 @@ public:
IdentifierInfo *II,
SourceLocation ColonLoc,
StmtArg SubStmt);
- virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal,
- StmtArg ThenVal, SourceLocation ElseLoc,
- StmtArg ElseVal);
+ virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
+ FullExprArg CondVal, StmtArg ThenVal,
+ SourceLocation ElseLoc, StmtArg ElseVal);
virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond);
virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
StmtArg Switch, StmtArg Body);
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp
index d59443b2cb..5c04c2491f 100644
--- a/lib/Sema/SemaStmt.cpp
+++ b/lib/Sema/SemaStmt.cpp
@@ -180,17 +180,19 @@ Sema::ActOnLabelStmt(SourceLocation IdentLoc, IdentifierInfo *II,
}
Action::OwningStmtResult
-Sema::ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal,
+Sema::ActOnIfStmt(SourceLocation IfLoc, FullExprArg CondVal,
StmtArg ThenVal, SourceLocation ElseLoc,
StmtArg ElseVal) {
- Expr *condExpr = CondVal.takeAs<Expr>();
+ OwningExprResult CondResult(CondVal.release());
+
+ Expr *condExpr = CondResult.takeAs<Expr>();
assert(condExpr && "ActOnIfStmt(): missing expression");
if (!condExpr->isTypeDependent()) {
DefaultFunctionArrayConversion(condExpr);
// Take ownership again until we're past the error checking.
- CondVal = condExpr;
+ CondResult = condExpr;
QualType condType = condExpr->getType();
if (getLangOptions().CPlusPlus) {
@@ -213,7 +215,7 @@ Sema::ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal,
Diag(stmt->getSemiLoc(), diag::warn_empty_if_body);
}
- CondVal.release();
+ CondResult.release();
return Owned(new (Context) IfStmt(IfLoc, condExpr, thenStmt,
ElseLoc, ElseVal.takeAs<Stmt>()));
}
diff --git a/lib/Sema/SemaTemplateInstantiateStmt.cpp b/lib/Sema/SemaTemplateInstantiateStmt.cpp
index 716bea7f7e..ce5ebb58dc 100644
--- a/lib/Sema/SemaTemplateInstantiateStmt.cpp
+++ b/lib/Sema/SemaTemplateInstantiateStmt.cpp
@@ -25,6 +25,10 @@ namespace {
Sema &SemaRef;
const TemplateArgumentList &TemplateArgs;
+ Sema::FullExprArg FullExpr(Sema::ExprArg &expr) {
+ return SemaRef.FullExpr(expr);
+ }
+
public:
typedef Sema::OwningExprResult OwningExprResult;
typedef Sema::OwningStmtResult OwningStmtResult;
@@ -225,7 +229,7 @@ Sema::OwningStmtResult TemplateStmtInstantiator::VisitIfStmt(IfStmt *S) {
if (Else.isInvalid())
return SemaRef.StmtError();
- return SemaRef.ActOnIfStmt(S->getIfLoc(), move(Cond), move(Then),
+ return SemaRef.ActOnIfStmt(S->getIfLoc(), FullExpr(Cond), move(Then),
S->getElseLoc(), move(Else));
}