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);



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89800 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/CodeGenCXX/condition.cpp b/test/CodeGenCXX/condition.cpp
index f3c8a9b..0bb9121 100644
--- a/test/CodeGenCXX/condition.cpp
+++ b/test/CodeGenCXX/condition.cpp
@@ -69,3 +69,23 @@
   // CHECK: store i32 20
   z = 20;
 }
+
+int foo();
+
+void while_destruct(int z) {
+  // CHECK: define void @_Z14while_destructi
+  // CHECK: while.cond: 
+  while (X x = X()) {
+    // CHECK: call void @_ZN1XC1Ev
+
+    // CHECK: while.body:
+    // CHECK: store i32 21
+    z = 21;
+
+    // CHECK: while.cleanup:
+    // CHECK: call void @_ZN1XD1Ev
+  }
+  // CHECK: while.end
+  // CHECK: store i32 22
+  z = 22;
+}