}
public:
- Type *getElementType() const { return ContainedTys[0]; }
+ Type *getElementType() const { return getSequentialElementType(); }
/// Methods for support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const Type *T) {
}
};
-Type *Type::getSequentialElementType() const {
- return cast<SequentialType>(this)->getElementType();
-}
-
/// ArrayType - Class to represent array types.
///
class ArrayType : public SequentialType {
/// (Integer, Double, Float).
Type * const *ContainedTys;
+ static bool isSequentialType(TypeID TyID) {
+ return TyID == ArrayTyID || TyID == PointerTyID || TyID == VectorTyID;
+ }
+
public:
void print(raw_ostream &O, bool IsForDebug = false) const;
void dump() const;
inline unsigned getStructNumElements() const;
inline Type *getStructElementType(unsigned N) const;
- inline Type *getSequentialElementType() const;
+ inline Type *getSequentialElementType() const {
+ assert(isSequentialType(getTypeID()) && "Not a sequential type!");
+ return ContainedTys[0];
+ }
inline uint64_t getArrayNumElements() const;
Type *getArrayElementType() const { return getSequentialElementType(); }