Implement getPrimitiveSize()
don't use isPointerType() llvm-svn: 2485
This commit is contained in:
parent
f4cdbf34e5
commit
398a86f14e
|
@ -87,8 +87,8 @@ const Type *Type::getPrimitiveType(PrimitiveID IDNumber) {
|
|||
//
|
||||
bool Type::isLosslesslyConvertableTo(const Type *Ty) const {
|
||||
if (this == Ty) return true;
|
||||
if ((!isPrimitiveType() && !isPointerType()) ||
|
||||
(!Ty->isPointerType() && !Ty->isPrimitiveType())) return false;
|
||||
if ((!isPrimitiveType() && !isa<PointerType>(this)) ||
|
||||
(!isa<PointerType>(Ty) && !Ty->isPrimitiveType())) return false;
|
||||
|
||||
if (getPrimitiveID() == Ty->getPrimitiveID())
|
||||
return true; // Handles identity cast, and cast of differing pointer types
|
||||
|
@ -110,6 +110,18 @@ bool Type::isLosslesslyConvertableTo(const Type *Ty) const {
|
|||
}
|
||||
}
|
||||
|
||||
// getPrimitiveSize - Return the basic size of this type if it is a primative
|
||||
// type. These are fixed by LLVM and are not target dependant. This will
|
||||
// return zero if the type does not have a size or is not a primitive type.
|
||||
//
|
||||
unsigned Type::getPrimitiveSize() const {
|
||||
switch (getPrimitiveID()) {
|
||||
#define HANDLE_PRIM_TYPE(TY,SIZE) case TY##TyID: return SIZE;
|
||||
#include "llvm/Type.def"
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool StructType::indexValid(const Value *V) const {
|
||||
if (!isa<Constant>(V)) return false;
|
||||
|
|
Loading…
Reference in New Issue