diff gen/statements.cpp @ 1412:3f5ea912149d

Fix #308 by giving finally code emitted by EnclosingTryFinally a different landing pad.
author Christian Kamm <kamm incasoftware de>
date Sat, 23 May 2009 00:23:39 +0200
parents 15e9762bb620
children 303e6422f785
line wrap: on
line diff
--- a/gen/statements.cpp	Fri May 22 21:38:01 2009 +0200
+++ b/gen/statements.cpp	Sat May 23 00:23:39 2009 +0200
@@ -592,8 +592,10 @@
     p->scope() = IRScope(landingpadbb, endbb);
 
     assert(finalbody);
-    gIR->func()->landingPad.addFinally(finalbody);
-    gIR->func()->landingPad.push(landingpadbb);
+    gIR->func()->targetScopes.push_back(IRTargetScope(this,new EnclosingTryFinally(this,gIR->func()->landingPad),NULL,NULL));
+    gIR->func()->landingPadInfo.addFinally(finalbody);
+    gIR->func()->landingPadInfo.push(landingpadbb);
+    gIR->func()->landingPad = gIR->func()->landingPadInfo.get();
 
     //
     // do the try block
@@ -601,15 +603,15 @@
     p->scope() = IRScope(trybb,finallybb);
 
     assert(body);
-    p->func()->targetScopes.push_back(IRTargetScope(this,new EnclosingTryFinally(this),NULL,NULL));
     body->toIR(p);
-    p->func()->targetScopes.pop_back();
 
     // terminate try BB
     if (!p->scopereturned())
         llvm::BranchInst::Create(finallybb, p->scopebb());
 
-    gIR->func()->landingPad.pop();
+    gIR->func()->landingPadInfo.pop();
+    gIR->func()->landingPad = gIR->func()->landingPadInfo.get();
+    gIR->func()->targetScopes.pop_back();
 
     //
     // do finally block
@@ -658,10 +660,11 @@
     for (int i = 0; i < catches->dim; i++)
     {
         Catch *c = (Catch *)catches->data[i];
-        gIR->func()->landingPad.addCatch(c, endbb);
+        gIR->func()->landingPadInfo.addCatch(c, endbb);
     }
 
-    gIR->func()->landingPad.push(landingpadbb);
+    gIR->func()->landingPadInfo.push(landingpadbb);
+    gIR->func()->landingPad = gIR->func()->landingPadInfo.get();
 
     //
     // do the try block
@@ -674,7 +677,8 @@
     if (!gIR->scopereturned())
         llvm::BranchInst::Create(endbb, p->scopebb());
 
-    gIR->func()->landingPad.pop();
+    gIR->func()->landingPadInfo.pop();
+    gIR->func()->landingPad = gIR->func()->landingPadInfo.get();
 
     // rewrite the scope
     p->scope() = IRScope(endbb,oldend);