mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-28 00:40:54 +00:00
Enforce that multiple return values have to have at least one result.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50137 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
69e6317083
commit
d52b62ae05
@ -155,6 +155,10 @@ public:
|
|||||||
bool isVarArg ///< Whether this is a variable argument length function
|
bool isVarArg ///< Whether this is a variable argument length function
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// isValidReturnType - Return true if the specified type is valid as a return
|
||||||
|
/// type.
|
||||||
|
static bool isValidReturnType(const Type *RetTy);
|
||||||
|
|
||||||
inline bool isVarArg() const { return isVarArgs; }
|
inline bool isVarArg() const { return isVarArgs; }
|
||||||
inline const Type *getReturnType() const { return ContainedTys[0]; }
|
inline const Type *getReturnType() const { return ContainedTys[0]; }
|
||||||
|
|
||||||
|
@ -2691,7 +2691,7 @@ bool GetResultInst::isValidOperands(const Value *Aggregate, unsigned Index) {
|
|||||||
|
|
||||||
if (const StructType *STy = dyn_cast<StructType>(Aggregate->getType())) {
|
if (const StructType *STy = dyn_cast<StructType>(Aggregate->getType())) {
|
||||||
unsigned NumElements = STy->getNumElements();
|
unsigned NumElements = STy->getNumElements();
|
||||||
if (Index >= NumElements)
|
if (Index >= NumElements || NumElements == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// getresult aggregate value's element types are restricted to
|
// getresult aggregate value's element types are restricted to
|
||||||
|
@ -437,16 +437,35 @@ const IntegerType *Type::Int64Ty = new BuiltinIntegerType(64);
|
|||||||
// Derived Type Constructors
|
// Derived Type Constructors
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
/// isValidReturnType - Return true if the specified type is valid as a return
|
||||||
|
/// type.
|
||||||
|
bool FunctionType::isValidReturnType(const Type *RetTy) {
|
||||||
|
if (RetTy->isFirstClassType())
|
||||||
|
return true;
|
||||||
|
if (RetTy == Type::VoidTy || isa<OpaqueType>(RetTy))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If this is a multiple return case, verify that each return is a first class
|
||||||
|
// value and that there is at least one value.
|
||||||
|
const StructType *SRetTy = dyn_cast<StructType>(RetTy);
|
||||||
|
if (SRetTy == 0 || SRetTy->getNumElements() == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = SRetTy->getNumElements(); i != e; ++i)
|
||||||
|
if (!SRetTy->getElementType(i)->isFirstClassType())
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
FunctionType::FunctionType(const Type *Result,
|
FunctionType::FunctionType(const Type *Result,
|
||||||
const std::vector<const Type*> &Params,
|
const std::vector<const Type*> &Params,
|
||||||
bool IsVarArgs)
|
bool IsVarArgs)
|
||||||
: DerivedType(FunctionTyID), isVarArgs(IsVarArgs) {
|
: DerivedType(FunctionTyID), isVarArgs(IsVarArgs) {
|
||||||
ContainedTys = reinterpret_cast<PATypeHandle*>(this+1);
|
ContainedTys = reinterpret_cast<PATypeHandle*>(this+1);
|
||||||
NumContainedTys = Params.size() + 1; // + 1 for result type
|
NumContainedTys = Params.size() + 1; // + 1 for result type
|
||||||
assert((Result->isFirstClassType() || Result == Type::VoidTy ||
|
assert(isValidReturnType(Result) && "invalid return type for function");
|
||||||
Result->getTypeID() == Type::StructTyID ||
|
|
||||||
isa<OpaqueType>(Result)) &&
|
|
||||||
"LLVM functions cannot return aggregates");
|
|
||||||
bool isAbstract = Result->isAbstract();
|
bool isAbstract = Result->isAbstract();
|
||||||
new (&ContainedTys[0]) PATypeHandle(Result, this);
|
new (&ContainedTys[0]) PATypeHandle(Result, this);
|
||||||
|
|
||||||
@ -1091,9 +1110,8 @@ FunctionType *FunctionType::get(const Type *ReturnType,
|
|||||||
bool isVarArg) {
|
bool isVarArg) {
|
||||||
FunctionValType VT(ReturnType, Params, isVarArg);
|
FunctionValType VT(ReturnType, Params, isVarArg);
|
||||||
FunctionType *FT = FunctionTypes->get(VT);
|
FunctionType *FT = FunctionTypes->get(VT);
|
||||||
if (FT) {
|
if (FT)
|
||||||
return FT;
|
return FT;
|
||||||
}
|
|
||||||
|
|
||||||
FT = (FunctionType*) new char[sizeof(FunctionType) +
|
FT = (FunctionType*) new char[sizeof(FunctionType) +
|
||||||
sizeof(PATypeHandle)*(Params.size()+1)];
|
sizeof(PATypeHandle)*(Params.size()+1)];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user