diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-05-25 21:28:11 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-05-25 21:28:11 +0000 |
commit | d67a1666ec70001ee9ce4c80ea5b0ab8e4f7a77b (patch) | |
tree | 076e15d8ce99e83dc4607b19e6cb50d56b6cdc52 | |
parent | d9b77159d65329e47a1dcf1bd6fb817e07bf99dc (diff) |
Audit the type constructors. Previously it was possible to create [0 x void]
or use labels as members of structures for example. Also included a couple of
whitespace fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72402 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Type.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 5dd91b3d07..1cab6ba9e2 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -322,15 +322,15 @@ FunctionType::FunctionType(const Type *Result, ContainedTys = reinterpret_cast<PATypeHandle*>(this+1); NumContainedTys = Params.size() + 1; // + 1 for result type assert(isValidReturnType(Result) && "invalid return type for function"); - - + + bool isAbstract = Result->isAbstract(); new (&ContainedTys[0]) PATypeHandle(Result, this); for (unsigned i = 0; i != Params.size(); ++i) { assert((Params[i]->isFirstClassType() || isa<OpaqueType>(Params[i])) && "Function arguments must be value types!"); - new (&ContainedTys[i+1]) PATypeHandle(Params[i],this); + new (&ContainedTys[i+1]) PATypeHandle(Params[i], this); isAbstract |= Params[i]->isAbstract(); } @@ -345,8 +345,10 @@ StructType::StructType(const std::vector<const Type*> &Types, bool isPacked) setSubclassData(isPacked); bool isAbstract = false; for (unsigned i = 0; i < Types.size(); ++i) { - assert(Types[i] != Type::VoidTy && "Void type for structure field!!"); - new (&ContainedTys[i]) PATypeHandle(Types[i], this); + assert(Types[i] && "<null> type for structure field!"); + assert(Types[i] != Type::VoidTy && "Void type for structure field!"); + assert(Types[i] != Type::LabelTy && "Label type for structure field!"); + new (&ContainedTys[i]) PATypeHandle(Types[i], this); isAbstract |= Types[i]->isAbstract(); } @@ -1038,7 +1040,9 @@ static ManagedStatic<TypeMap<ArrayValType, ArrayType> > ArrayTypes; ArrayType *ArrayType::get(const Type *ElementType, uint64_t NumElements) { - assert(ElementType && "Can't get array of null types!"); + assert(ElementType && "Can't get array of <null> types!"); + assert(ElementType != Type::VoidTy && "Array of void is not valid!"); + assert(ElementType != Type::LabelTy && "Array of labels is not valid!"); ArrayValType AVT(ElementType, NumElements); ArrayType *AT = ArrayTypes->get(AVT); @@ -1082,7 +1086,7 @@ static ManagedStatic<TypeMap<VectorValType, VectorType> > VectorTypes; VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) { - assert(ElementType && "Can't get vector of null types!"); + assert(ElementType && "Can't get vector of <null> types!"); VectorValType PVT(ElementType, NumElements); VectorType *PT = VectorTypes->get(PVT); |