mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 02:45:25 +03:00
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.
This commit is contained in:
parent
202c4f7bc2
commit
180487b614
4 changed files with 29 additions and 13 deletions
|
@ -1137,7 +1137,7 @@ DValue* DtoDeclarationExp(Dsymbol* declaration)
|
|||
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());
|
||||
|
|
|
@ -1172,9 +1172,8 @@ void WithStatement::toIR(IRState* p)
|
|||
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);
|
||||
|
|
18
gen/toir.cpp
18
gen/toir.cpp
|
@ -620,7 +620,7 @@ DValue* MinAssignExp::toElem(IRState* p)
|
|||
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 @@ DValue* PostExp::toElem(IRState* p)
|
|||
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 @@ DValue* PostExp::toElem(IRState* p)
|
|||
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* AndAndExp::toElem(IRState* p)
|
|||
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 @@ DValue* X##Exp::toElem(IRState* p) \
|
|||
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* X##AssignExp::toElem(IRState* p) \
|
|||
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 @@ DValue* ComExp::toElem(IRState* p)
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
17
tests/mini/with2.d
Normal file
17
tests/mini/with2.d
Normal file
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue