Pull CodeGenFunction::GetUndefRValue() out of EmitUnsupportedRValue.

llvm-svn: 63845
This commit is contained in:
Daniel Dunbar 2009-02-05 07:09:07 +00:00
parent 9103df1688
commit c79407fc40
3 changed files with 20 additions and 19 deletions

View File

@ -1430,17 +1430,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
return RValue::get(CI); return RValue::get(CI);
case ABIArgInfo::Ignore: case ABIArgInfo::Ignore:
if (RetTy->isVoidType())
return RValue::get(0);
// If we are ignoring an argument that had a result, make sure to // If we are ignoring an argument that had a result, make sure to
// construct the appropriate return value for our caller. // construct the appropriate return value for our caller.
if (CodeGenFunction::hasAggregateLLVMType(RetTy)) { return GetUndefRValue(RetTy);
llvm::Value *Res = if (RetTy->isVoidType())
llvm::UndefValue::get(llvm::PointerType::getUnqual(ConvertType(RetTy))); return RValue::get(0);
return RValue::getAggregate(Res);
}
return RValue::get(llvm::UndefValue::get(ConvertType(RetTy)));
case ABIArgInfo::Coerce: { case ABIArgInfo::Coerce: {
// FIXME: Avoid the conversion through memory if possible. // FIXME: Avoid the conversion through memory if possible.

View File

@ -83,23 +83,27 @@ unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx,
// LValue Expression Emission // LValue Expression Emission
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
RValue CodeGenFunction::EmitUnsupportedRValue(const Expr *E, RValue CodeGenFunction::GetUndefRValue(QualType Ty) {
const char *Name) { if (Ty->isVoidType()) {
ErrorUnsupported(E, Name); return RValue::get(0);
if (const ComplexType *CTy = E->getType()->getAsComplexType()) { } else if (const ComplexType *CTy = Ty->getAsComplexType()) {
const llvm::Type *EltTy = ConvertType(CTy->getElementType()); const llvm::Type *EltTy = ConvertType(CTy->getElementType());
llvm::Value *U = llvm::UndefValue::get(EltTy); llvm::Value *U = llvm::UndefValue::get(EltTy);
return RValue::getComplex(std::make_pair(U, U)); return RValue::getComplex(std::make_pair(U, U));
} else if (hasAggregateLLVMType(E->getType())) { } else if (hasAggregateLLVMType(Ty)) {
const llvm::Type *Ty = const llvm::Type *LTy = llvm::PointerType::getUnqual(ConvertType(Ty));
llvm::PointerType::getUnqual(ConvertType(E->getType())); return RValue::getAggregate(llvm::UndefValue::get(LTy));
return RValue::getAggregate(llvm::UndefValue::get(Ty));
} else { } else {
const llvm::Type *Ty = ConvertType(E->getType()); return RValue::get(llvm::UndefValue::get(ConvertType(Ty)));
return RValue::get(llvm::UndefValue::get(Ty));
} }
} }
RValue CodeGenFunction::EmitUnsupportedRValue(const Expr *E,
const char *Name) {
ErrorUnsupported(E, Name);
return GetUndefRValue(E->getType());
}
LValue CodeGenFunction::EmitUnsupportedLValue(const Expr *E, LValue CodeGenFunction::EmitUnsupportedLValue(const Expr *E,
const char *Name) { const char *Name) {
ErrorUnsupported(E, Name); ErrorUnsupported(E, Name);

View File

@ -450,6 +450,9 @@ public:
// LValue Expression Emission // LValue Expression Emission
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
/// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
RValue GetUndefRValue(QualType Ty);
/// EmitUnsupportedRValue - Emit a dummy r-value using the type of E /// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
/// and issue an ErrorUnsupported style diagnostic (using the /// and issue an ErrorUnsupported style diagnostic (using the
/// provided Name). /// provided Name).