GlobalObject(const GlobalObject &) = delete;
protected:
- GlobalObject(PointerType *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
- LinkageTypes Linkage, const Twine &Name) = delete;
GlobalObject(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
LinkageTypes Linkage, const Twine &Name,
unsigned AddressSpace = 0)
- : GlobalValue(PointerType::get(Ty, AddressSpace), VTy, Ops, NumOps,
- Linkage, Name),
+ : GlobalValue(Ty, VTy, Ops, NumOps, Linkage, Name, AddressSpace),
ObjComdat(nullptr) {
setGlobalValueSubClassData(0);
}
};
protected:
- GlobalValue(PointerType *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
- LinkageTypes Linkage, const Twine &Name)
- : Constant(Ty, VTy, Ops, NumOps), Linkage(Linkage),
- Visibility(DefaultVisibility), UnnamedAddr(0),
- DllStorageClass(DefaultStorageClass),
+ GlobalValue(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
+ LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace)
+ : Constant(PointerType::get(Ty, AddressSpace), VTy, Ops, NumOps),
+ ValueType(Ty), Linkage(Linkage), Visibility(DefaultVisibility),
+ UnnamedAddr(0), DllStorageClass(DefaultStorageClass),
ThreadLocal(NotThreadLocal), IntID((Intrinsic::ID)0U), Parent(nullptr) {
setName(Name);
}
+ Type *ValueType;
// Note: VC++ treats enums as signed, so an extra bit is required to prevent
// Linkage and Visibility from turning into negative values.
LinkageTypes Linkage : 5; // The linkage of this global
/// Global values are always pointers.
PointerType *getType() const { return cast<PointerType>(User::getType()); }
- Type *getValueType() const { return getType()->getElementType(); }
+ Type *getValueType() const { return ValueType; }
static LinkageTypes getLinkOnceLinkage(bool ODR) {
return ODR ? LinkOnceODRLinkage : LinkOnceAnyLinkage;
GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
const Twine &Name, Constant *Aliasee,
Module *ParentModule)
- : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalAliasVal,
- &Op<0>(), 1, Link, Name) {
+ : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name,
+ AddressSpace) {
Op<0>() = Aliasee;
if (ParentModule)