Apply patch from klickverbot. This is his 'proper fix' patch for bug #395.

This commit is contained in:
Kelly Wilson 2010-03-08 23:37:40 -07:00
parent 902bc06fb1
commit b38845e88e
6 changed files with 45 additions and 51 deletions

View file

@ -1572,3 +1572,36 @@ Type * stripModifiers( Type * type )
}
//////////////////////////////////////////////////////////////////////////////////////////
LLValue* makeLValue(Loc& loc, DValue* value)
{
Type* valueType = value->getType();
bool needsMemory;
LLValue* valuePointer;
if (value->isIm()) {
valuePointer = value->getRVal();
needsMemory = !DtoIsPassedByRef(valueType);
}
else if (DVarValue* var = value->isVar()) {
valuePointer = value->getLVal();
needsMemory = false;
}
else if (value->isConst()) {
valuePointer = value->getRVal();
needsMemory = true;
}
else {
valuePointer = DtoAlloca(valueType, ".makelvaluetmp");
DVarValue var(valueType, valuePointer);
DtoAssign(loc, &var, value);
needsMemory = false;
}
if (needsMemory) {
LLValue* tmp = DtoAlloca(valueType, ".makelvaluetmp");
DtoStore(valuePointer, tmp);
valuePointer = tmp;
}
return valuePointer;
}