302
296
bool isPacked() const { return (0 != getSubclassData()) ? true : false; }
306
/// UnionType - Class to represent union types. A union type is similar to
307
/// a structure, except that all member fields begin at offset 0.
309
class UnionType : public CompositeType {
310
friend class TypeMap<UnionValType, UnionType>;
311
UnionType(const UnionType &); // Do not implement
312
const UnionType &operator=(const UnionType &); // Do not implement
313
UnionType(LLVMContext &C, const Type* const* Types, unsigned NumTypes);
315
/// UnionType::get - This static method is the primary way to create a
317
static UnionType *get(const Type* const* Types, unsigned NumTypes);
319
/// UnionType::get - This static method is a convenience method for
320
/// creating union types by specifying the elements as arguments.
321
static UnionType *get(const Type *type, ...) END_WITH_NULL;
323
/// isValidElementType - Return true if the specified type is valid as a
325
static bool isValidElementType(const Type *ElemTy);
327
/// Given an element type, return the member index of that type, or -1
328
/// if there is no such member type.
329
int getElementTypeIndex(const Type *ElemTy) const;
331
// Iterator access to the elements
332
typedef Type::subtype_iterator element_iterator;
333
element_iterator element_begin() const { return ContainedTys; }
334
element_iterator element_end() const { return &ContainedTys[NumContainedTys];}
336
// Random access to the elements
337
unsigned getNumElements() const { return NumContainedTys; }
338
const Type *getElementType(unsigned N) const {
339
assert(N < NumContainedTys && "Element number out of range!");
340
return ContainedTys[N];
343
/// getTypeAtIndex - Given an index value into the type, return the type of
344
/// the element. For a union type, this must be a constant value...
346
virtual const Type *getTypeAtIndex(const Value *V) const;
347
virtual const Type *getTypeAtIndex(unsigned Idx) const;
348
virtual bool indexValid(const Value *V) const;
349
virtual bool indexValid(unsigned Idx) const;
351
// Implement the AbstractTypeUser interface.
352
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
353
virtual void typeBecameConcrete(const DerivedType *AbsTy);
355
// Methods for support type inquiry through isa, cast, and dyn_cast:
356
static inline bool classof(const UnionType *) { return true; }
357
static inline bool classof(const Type *T) {
358
return T->getTypeID() == UnionTyID;
363
299
/// SequentialType - This is the superclass of the array, pointer and vector
364
300
/// type classes. All of these represent "arrays" in memory. The array type
365
301
/// represents a specifically sized array, pointer types are unsized/unknown