Add a utility to get a RValue for a given LValue for an aggregate; switch a few places over to it.

llvm-svn: 145747
This commit is contained in:
Eli Friedman 2011-12-03 03:08:40 +00:00
parent ef3ad87ac6
commit 2869b5afe3
3 changed files with 9 additions and 7 deletions

View File

@ -1463,8 +1463,7 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
cast<CastExpr>(E)->getCastKind() == CK_LValueToRValue) {
LValue L = EmitLValue(cast<CastExpr>(E)->getSubExpr());
assert(L.isSimple());
args.add(RValue::getAggregate(L.getAddress(), L.isVolatileQualified()),
type, /*NeedsCopy*/true);
args.add(L.asAggregateRValue(), type, /*NeedsCopy*/true);
return;
}
@ -1518,7 +1517,7 @@ void CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
// FIXME: Volatile?
EltRV = RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
else if (CodeGenFunction::hasAggregateLLVMType(EltTy))
EltRV = RValue::getAggregate(LV.getAddress());
EltRV = LV.asAggregateRValue();
else
EltRV = EmitLoadOfLValue(LV);
ExpandTypeToArgs(EltTy, EltRV, Args, IRFuncTy);
@ -1539,7 +1538,7 @@ void CodeGenFunction::ExpandTypeToArgs(QualType Ty, RValue RV,
// FIXME: Volatile?
FldRV = RValue::getComplex(LoadComplexFromAddr(LV.getAddress(), false));
else if (CodeGenFunction::hasAggregateLLVMType(FT))
FldRV = RValue::getAggregate(LV.getAddress());
FldRV = LV.asAggregateRValue();
else
FldRV = EmitLoadOfLValue(LV);
ExpandTypeToArgs(FT, FldRV, Args, IRFuncTy);

View File

@ -263,9 +263,7 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, RValue Src, bool Ignore) {
void AggExprEmitter::EmitFinalDestCopy(const Expr *E, LValue Src, bool Ignore) {
assert(Src.isSimple() && "Can't have aggregate bitfield, vector, etc");
EmitFinalDestCopy(E, RValue::getAggregate(Src.getAddress(),
Src.isVolatileQualified()),
Ignore);
EmitFinalDestCopy(E, Src.asAggregateRValue(), Ignore);
}
//===----------------------------------------------------------------------===//

View File

@ -300,6 +300,11 @@ public:
R.Initialize(type, type.getQualifiers());
return R;
}
RValue asAggregateRValue() const {
// FIMXE: Alignment
return RValue::getAggregate(getAddress(), isVolatileQualified());
}
};
/// An aggregate value slot.