summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/TreeTransform.h
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-24 21:15:44 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-24 21:15:44 +0000
commit680f861d74f39bb29ad87346f764da7cc392c5aa (patch)
tree5b58f11c0249187ebfd9e8ea7081a5050f61015a /clang/lib/Sema/TreeTransform.h
parent3c9beab48a6af525b851bfc44b55ddb2b35c5237 (diff)
downloadbcm5719-llvm-680f861d74f39bb29ad87346f764da7cc392c5aa.tar.gz
bcm5719-llvm-680f861d74f39bb29ad87346f764da7cc392c5aa.zip
Clean up the AST for while loops and fix several problems with
cleanups for while loops: 1) Make sure that we destroy the condition variable of a while statement each time through the loop for, e.g., while (shared_ptr<WorkInt> p = getWorkItem()) { // ... } 2) Make sure that we always enter a new cleanup scope for the body of the while loop, even when there is no compound expression, e.g., while (blah) RAIIObject raii(blah+1); llvm-svn: 89800
Diffstat (limited to 'clang/lib/Sema/TreeTransform.h')
-rw-r--r--clang/lib/Sema/TreeTransform.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index e1d0bba4a4e..202e16e31e3 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -3139,7 +3139,18 @@ template<typename Derived>
Sema::OwningStmtResult
TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
// Transform the condition
- OwningExprResult Cond = getDerived().TransformExpr(S->getCond());
+ OwningExprResult Cond(SemaRef);
+ VarDecl *ConditionVar = 0;
+ if (S->getConditionVariable()) {
+ ConditionVar
+ = cast_or_null<VarDecl>(
+ getDerived().TransformDefinition(S->getConditionVariable()));
+ if (!ConditionVar)
+ return SemaRef.StmtError();
+
+ Cond = getSema().CheckConditionVariable(ConditionVar);
+ } else
+ Cond = getDerived().TransformExpr(S->getCond());
if (Cond.isInvalid())
return SemaRef.StmtError();
OpenPOWER on IntegriCloud