[Alignment][NFC] Remove dependency on GlobalObject::setAlignment(unsigned)
[llvm-core.git] / include / llvm / IR / GlobalAlias.h
blobf2d9b9676ec96c5f08e04488412d486d225ac433
1 //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the GlobalAlias class, which
10 // represents a single function or variable alias in the IR.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_IR_GLOBALALIAS_H
15 #define LLVM_IR_GLOBALALIAS_H
17 #include "llvm/ADT/ilist_node.h"
18 #include "llvm/IR/GlobalIndirectSymbol.h"
19 #include "llvm/IR/Value.h"
21 namespace llvm {
23 class Twine;
24 class Module;
25 template <typename ValueSubClass> class SymbolTableListTraits;
27 class GlobalAlias : public GlobalIndirectSymbol,
28 public ilist_node<GlobalAlias> {
29 friend class SymbolTableListTraits<GlobalAlias>;
31 GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage,
32 const Twine &Name, Constant *Aliasee, Module *Parent);
34 public:
35 GlobalAlias(const GlobalAlias &) = delete;
36 GlobalAlias &operator=(const GlobalAlias &) = delete;
38 /// If a parent module is specified, the alias is automatically inserted into
39 /// the end of the specified module's alias list.
40 static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
41 LinkageTypes Linkage, const Twine &Name,
42 Constant *Aliasee, Module *Parent);
44 // Without the Aliasee.
45 static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
46 LinkageTypes Linkage, const Twine &Name,
47 Module *Parent);
49 // The module is taken from the Aliasee.
50 static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
51 LinkageTypes Linkage, const Twine &Name,
52 GlobalValue *Aliasee);
54 // Type, Parent and AddressSpace taken from the Aliasee.
55 static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name,
56 GlobalValue *Aliasee);
58 // Linkage, Type, Parent and AddressSpace taken from the Aliasee.
59 static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee);
61 /// removeFromParent - This method unlinks 'this' from the containing module,
62 /// but does not delete it.
63 ///
64 void removeFromParent();
66 /// eraseFromParent - This method unlinks 'this' from the containing module
67 /// and deletes it.
68 ///
69 void eraseFromParent();
71 /// These methods retrieve and set alias target.
72 void setAliasee(Constant *Aliasee);
73 const Constant *getAliasee() const {
74 return getIndirectSymbol();
76 Constant *getAliasee() {
77 return getIndirectSymbol();
80 static bool isValidLinkage(LinkageTypes L) {
81 return isExternalLinkage(L) || isLocalLinkage(L) ||
82 isWeakLinkage(L) || isLinkOnceLinkage(L);
85 // Methods for support type inquiry through isa, cast, and dyn_cast:
86 static bool classof(const Value *V) {
87 return V->getValueID() == Value::GlobalAliasVal;
91 } // end namespace llvm
93 #endif // LLVM_IR_GLOBALALIAS_H