File indexing completed on 2026-05-10 08:44:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_IR_GLOBALALIAS_H
0015 #define LLVM_IR_GLOBALALIAS_H
0016
0017 #include "llvm/ADT/ilist_node.h"
0018 #include "llvm/IR/GlobalValue.h"
0019 #include "llvm/IR/OperandTraits.h"
0020 #include "llvm/IR/Value.h"
0021
0022 namespace llvm {
0023
0024 class Twine;
0025 class Module;
0026 template <typename ValueSubClass, typename... Args> class SymbolTableListTraits;
0027
0028 class GlobalAlias : public GlobalValue, public ilist_node<GlobalAlias> {
0029 friend class SymbolTableListTraits<GlobalAlias>;
0030
0031 constexpr static IntrusiveOperandsAllocMarker AllocMarker{1};
0032
0033 GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
0034 const Twine &Name, Constant *Aliasee, Module *Parent);
0035
0036 public:
0037 GlobalAlias(const GlobalAlias &) = delete;
0038 GlobalAlias &operator=(const GlobalAlias &) = delete;
0039
0040
0041
0042 static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
0043 LinkageTypes Linkage, const Twine &Name,
0044 Constant *Aliasee, Module *Parent);
0045
0046
0047 static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
0048 LinkageTypes Linkage, const Twine &Name,
0049 Module *Parent);
0050
0051
0052 static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
0053 LinkageTypes Linkage, const Twine &Name,
0054 GlobalValue *Aliasee);
0055
0056
0057 static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name,
0058 GlobalValue *Aliasee);
0059
0060
0061 static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
0062
0063
0064 void *operator new(size_t S) { return User::operator new(S, AllocMarker); }
0065 void operator delete(void *Ptr) { User::operator delete(Ptr); }
0066
0067
0068 DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant);
0069
0070 void copyAttributesFrom(const GlobalAlias *Src) {
0071 GlobalValue::copyAttributesFrom(Src);
0072 }
0073
0074
0075
0076
0077 void removeFromParent();
0078
0079
0080
0081
0082 void eraseFromParent();
0083
0084
0085 void setAliasee(Constant *Aliasee);
0086 const Constant *getAliasee() const {
0087 return static_cast<Constant *>(Op<0>().get());
0088 }
0089 Constant *getAliasee() { return static_cast<Constant *>(Op<0>().get()); }
0090
0091 const GlobalObject *getAliaseeObject() const;
0092 GlobalObject *getAliaseeObject() {
0093 return const_cast<GlobalObject *>(
0094 static_cast<const GlobalAlias *>(this)->getAliaseeObject());
0095 }
0096
0097 static bool isValidLinkage(LinkageTypes L) {
0098 return isExternalLinkage(L) || isLocalLinkage(L) || isWeakLinkage(L) ||
0099 isLinkOnceLinkage(L) || isAvailableExternallyLinkage(L);
0100 }
0101
0102
0103 static bool classof(const Value *V) {
0104 return V->getValueID() == Value::GlobalAliasVal;
0105 }
0106 };
0107
0108 template <>
0109 struct OperandTraits<GlobalAlias>
0110 : public FixedNumOperandTraits<GlobalAlias, 1> {};
0111
0112 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GlobalAlias, Constant)
0113
0114 }
0115
0116 #endif