From c79407fc4077ba5ba8a72e7fc64bfbba777f333c Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 5 Feb 2009 07:09:07 +0000 Subject: [PATCH] Pull CodeGenFunction::GetUndefRValue() out of EmitUnsupportedRValue. llvm-svn: 63845 --- clang/lib/CodeGen/CGCall.cpp | 12 +++--------- clang/lib/CodeGen/CGExpr.cpp | 24 ++++++++++++++---------- clang/lib/CodeGen/CodeGenFunction.h | 3 +++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index b7459b222993..0d0dd33d4765 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1430,17 +1430,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, return RValue::get(CI); case ABIArgInfo::Ignore: - if (RetTy->isVoidType()) - return RValue::get(0); - // If we are ignoring an argument that had a result, make sure to // construct the appropriate return value for our caller. - if (CodeGenFunction::hasAggregateLLVMType(RetTy)) { - llvm::Value *Res = - llvm::UndefValue::get(llvm::PointerType::getUnqual(ConvertType(RetTy))); - return RValue::getAggregate(Res); - } - return RValue::get(llvm::UndefValue::get(ConvertType(RetTy))); + return GetUndefRValue(RetTy); + if (RetTy->isVoidType()) + return RValue::get(0); case ABIArgInfo::Coerce: { // FIXME: Avoid the conversion through memory if possible. diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index f085127da2ab..5e969308b0ca 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -83,23 +83,27 @@ unsigned CodeGenFunction::getAccessedFieldNo(unsigned Idx, // LValue Expression Emission //===----------------------------------------------------------------------===// -RValue CodeGenFunction::EmitUnsupportedRValue(const Expr *E, - const char *Name) { - ErrorUnsupported(E, Name); - if (const ComplexType *CTy = E->getType()->getAsComplexType()) { +RValue CodeGenFunction::GetUndefRValue(QualType Ty) { + if (Ty->isVoidType()) { + return RValue::get(0); + } else if (const ComplexType *CTy = Ty->getAsComplexType()) { const llvm::Type *EltTy = ConvertType(CTy->getElementType()); llvm::Value *U = llvm::UndefValue::get(EltTy); return RValue::getComplex(std::make_pair(U, U)); - } else if (hasAggregateLLVMType(E->getType())) { - const llvm::Type *Ty = - llvm::PointerType::getUnqual(ConvertType(E->getType())); - return RValue::getAggregate(llvm::UndefValue::get(Ty)); + } else if (hasAggregateLLVMType(Ty)) { + const llvm::Type *LTy = llvm::PointerType::getUnqual(ConvertType(Ty)); + return RValue::getAggregate(llvm::UndefValue::get(LTy)); } else { - const llvm::Type *Ty = ConvertType(E->getType()); - return RValue::get(llvm::UndefValue::get(Ty)); + return RValue::get(llvm::UndefValue::get(ConvertType(Ty))); } } +RValue CodeGenFunction::EmitUnsupportedRValue(const Expr *E, + const char *Name) { + ErrorUnsupported(E, Name); + return GetUndefRValue(E->getType()); +} + LValue CodeGenFunction::EmitUnsupportedLValue(const Expr *E, const char *Name) { ErrorUnsupported(E, Name); diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index ab145d7a1e92..bf27d0aceab6 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -450,6 +450,9 @@ public: // 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 /// and issue an ErrorUnsupported style diagnostic (using the /// provided Name).