summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-11-25 00:27:52 +0000
committerDouglas Gregor <dgregor@apple.com>2009-11-25 00:27:52 +0000
commit7bab5ff8e70c2f5076a26bcc6099b81c06a4de9a (patch)
treeb63c8c9608093b38f19e045cbbdfaa29698a044d /clang/lib/CodeGen/CGStmt.cpp
parentd6f7850117e25b64b9f79a1b30e30293db3ae95a (diff)
downloadbcm5719-llvm-7bab5ff8e70c2f5076a26bcc6099b81c06a4de9a.tar.gz
bcm5719-llvm-7bab5ff8e70c2f5076a26bcc6099b81c06a4de9a.zip
Eliminate CXXConditionDeclExpr with extreme prejudice.
All statements that involve conditions can now hold on to a separate condition declaration (a VarDecl), and will use a DeclRefExpr referring to that VarDecl for the condition expression. ForStmts now have such a VarDecl (I'd missed those in previous commits). Also, since this change reworks the Action interface for if/while/switch/for, use FullExprArg for the full expressions in those expressions, to ensure that we're emitting Note that we are (still) not generating the right cleanups for condition variables in for statements. That will be a follow-on commit. llvm-svn: 89817
Diffstat (limited to 'clang/lib/CodeGen/CGStmt.cpp')
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 6fddcf6b041..be571fac717 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -479,6 +479,7 @@ void CodeGenFunction::EmitDoStmt(const DoStmt &S) {
void CodeGenFunction::EmitForStmt(const ForStmt &S) {
// FIXME: What do we do if the increment (f.e.) contains a stmt expression,
// which contains a continue/break?
+ CleanupScope ForScope(*this);
// Evaluate the first part before the loop.
if (S.getInit())
@@ -490,9 +491,18 @@ void CodeGenFunction::EmitForStmt(const ForStmt &S) {
EmitBlock(CondBlock);
+ // Create a cleanup scope
+ CleanupScope ConditionScope(*this);
+
// Evaluate the condition if present. If not, treat it as a
// non-zero-constant according to 6.8.5.3p2, aka, true.
if (S.getCond()) {
+ // If the for statement has a condition scope, emit the local variable
+ // declaration.
+ // FIXME: The cleanup points for this are all wrong.
+ if (S.getConditionVariable())
+ EmitLocalBlockVarDecl(*S.getConditionVariable());
+
// As long as the condition is true, iterate the loop.
llvm::BasicBlock *ForBody = createBasicBlock("for.body");
OpenPOWER on IntegriCloud