summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/IR/DerivedTypes.h6
-rw-r--r--llvm/include/llvm/IR/Type.h9
2 files changed, 9 insertions, 6 deletions
diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 071e69b1e80..afb0492258e 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -343,7 +343,7 @@ protected:
}
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) {
@@ -353,10 +353,6 @@ public:
}
};
-Type *Type::getSequentialElementType() const {
- return cast<SequentialType>(this)->getElementType();
-}
-
/// ArrayType - Class to represent array types.
///
class ArrayType : public SequentialType {
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index b2920dd3de6..4b2b9724ba5 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -107,6 +107,10 @@ protected:
/// (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;
@@ -347,7 +351,10 @@ public:
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(); }
OpenPOWER on IntegriCloud