[llvm] r259190 - [IR] Shuffle the code for getSequentialElementType to type.h to avoid circular header dependencies.

Benjamin Kramer via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 29 04:47:02 PST 2016


Author: d0k
Date: Fri Jan 29 06:47:01 2016
New Revision: 259190

URL: http://llvm.org/viewvc/llvm-project?rev=259190&view=rev
Log:
[IR] Shuffle the code for getSequentialElementType to type.h to avoid circular header dependencies.

Modified:
    llvm/trunk/include/llvm/IR/DerivedTypes.h
    llvm/trunk/include/llvm/IR/Type.h

Modified: llvm/trunk/include/llvm/IR/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DerivedTypes.h?rev=259190&r1=259189&r2=259190&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DerivedTypes.h (original)
+++ llvm/trunk/include/llvm/IR/DerivedTypes.h Fri Jan 29 06:47:01 2016
@@ -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 {

Modified: llvm/trunk/include/llvm/IR/Type.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Type.h?rev=259190&r1=259189&r2=259190&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Type.h (original)
+++ llvm/trunk/include/llvm/IR/Type.h Fri Jan 29 06:47:01 2016
@@ -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(); }




More information about the llvm-commits mailing list