changeset 704:43165a082535

Fixed issue with accessing a WithStatement context from inside a nested function. see mini/with2.d Renamed some LLVM uses of ::create statics to ::Create , lower case ones will be deprecated soon.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 14 Oct 2008 13:21:14 +0200
parents 06576ece1a1b
children 5a2983f97498
files gen/llvmhelpers.cpp gen/statements.cpp gen/toir.cpp tests/mini/with2.d
diffstat 4 files changed, 29 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/gen/llvmhelpers.cpp	Mon Oct 13 23:19:32 2008 +0200
+++ b/gen/llvmhelpers.cpp	Tue Oct 14 13:21:14 2008 +0200
@@ -1137,7 +1137,7 @@
                 Logger::println("has nestedref set");
                 assert(vd->ir.irLocal);
                 
-                // alloca as usual is no value already
+                // alloca as usual if no value already
                 if (!vd->ir.irLocal->value)
                 {
                     vd->ir.irLocal->value = DtoAlloca(DtoType(vd->type), vd->toChars());
--- a/gen/statements.cpp	Mon Oct 13 23:19:32 2008 +0200
+++ b/gen/statements.cpp	Tue Oct 14 13:21:14 2008 +0200
@@ -1172,9 +1172,8 @@
     assert(body);
 
     DValue* e = exp->toElem(p);
-    assert(!wthis->ir.isSet());
-    wthis->ir.irLocal = new IrLocal(wthis);
-    wthis->ir.irLocal->value = DtoAlloca(DtoType(wthis->type), wthis->toChars());
+
+    DtoDeclarationExp(wthis);
     DtoStore(e->getRVal(), wthis->ir.irLocal->value);
 
     body->toIR(p);
--- a/gen/toir.cpp	Mon Oct 13 23:19:32 2008 +0200
+++ b/gen/toir.cpp	Tue Oct 14 13:21:14 2008 +0200
@@ -620,7 +620,7 @@
         Logger::println("ptr");
         LLValue* tmp = r->getRVal();
         LLValue* zero = llvm::ConstantInt::get(tmp->getType(),0,false);
-        tmp = llvm::BinaryOperator::createSub(zero,tmp,"tmp",p->scopebb());
+        tmp = llvm::BinaryOperator::CreateSub(zero,tmp,"tmp",p->scopebb());
         tmp = llvm::GetElementPtrInst::Create(l->getRVal(),tmp,"tmp",p->scopebb());
         res = new DImValue(type, tmp);
     }
@@ -1412,10 +1412,10 @@
         assert(e2type->isintegral());
         LLValue* one = llvm::ConstantInt::get(val->getType(), 1, !e2type->isunsigned());
         if (op == TOKplusplus) {
-            post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb());
+            post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb());
         }
         else if (op == TOKminusminus) {
-            post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb());
+            post = llvm::BinaryOperator::CreateSub(val,one,"tmp",p->scopebb());
         }
     }
     else if (e1type->ty == Tpointer)
@@ -1431,10 +1431,10 @@
         assert(e2type->isfloating());
         LLValue* one = DtoConstFP(e1type, 1.0);
         if (op == TOKplusplus) {
-            post = llvm::BinaryOperator::createAdd(val,one,"tmp",p->scopebb());
+            post = llvm::BinaryOperator::CreateAdd(val,one,"tmp",p->scopebb());
         }
         else if (op == TOKminusminus) {
-            post = llvm::BinaryOperator::createSub(val,one,"tmp",p->scopebb());
+            post = llvm::BinaryOperator::CreateSub(val,one,"tmp",p->scopebb());
         }
     }
     else
@@ -1700,7 +1700,7 @@
     DValue* v = e2->toElem(p);
 
     LLValue* vbool = DtoBoolean(loc, v);
-    LLValue* uandvbool = llvm::BinaryOperator::create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb());
+    LLValue* uandvbool = llvm::BinaryOperator::Create(llvm::BinaryOperator::And, ubool, vbool,"tmp",p->scopebb());
     DtoStore(uandvbool,resval);
     llvm::BranchInst::Create(andandend,p->scopebb());
 
@@ -1754,7 +1754,7 @@
     LOG_SCOPE; \
     DValue* u = e1->toElem(p); \
     DValue* v = e2->toElem(p); \
-    LLValue* x = llvm::BinaryOperator::create(llvm::Instruction::Y, u->getRVal(), v->getRVal(), "tmp", p->scopebb()); \
+    LLValue* x = llvm::BinaryOperator::Create(llvm::Instruction::Y, u->getRVal(), v->getRVal(), "tmp", p->scopebb()); \
     return new DImValue(type, x); \
 } \
 \
@@ -1766,7 +1766,7 @@
     DValue* v = e2->toElem(p); \
     LLValue* uval = u->getRVal(); \
     LLValue* vval = v->getRVal(); \
-    LLValue* tmp = llvm::BinaryOperator::create(llvm::Instruction::Y, uval, vval, "tmp", p->scopebb()); \
+    LLValue* tmp = llvm::BinaryOperator::Create(llvm::Instruction::Y, uval, vval, "tmp", p->scopebb()); \
     DtoStore(DtoPointedType(u->getLVal(), tmp), u->getLVal()); \
     return u; \
 }
@@ -2022,7 +2022,7 @@
 
     LLValue* value = u->getRVal();
     LLValue* minusone = llvm::ConstantInt::get(value->getType(), -1, true);
-    value = llvm::BinaryOperator::create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb());
+    value = llvm::BinaryOperator::Create(llvm::Instruction::Xor, value, minusone, "tmp", p->scopebb());
 
     return new DImValue(type, value);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/mini/with2.d	Tue Oct 14 13:21:14 2008 +0200
@@ -0,0 +1,17 @@
+struct bar {
+    int bar;
+}
+
+void main() {
+    bar Bar;
+    with (Bar)
+    {
+        assert(Bar.bar == 0);
+        void test()
+        {
+            bar ++;
+        }
+        test();
+    }
+    assert(Bar.bar == 1);
+}