/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/IR/GlobalAlias.h
Line | Count | Source |
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. |
11 | | // |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #ifndef LLVM_IR_GLOBALALIAS_H |
15 | | #define LLVM_IR_GLOBALALIAS_H |
16 | | |
17 | | #include "llvm/ADT/ilist_node.h" |
18 | | #include "llvm/IR/GlobalIndirectSymbol.h" |
19 | | #include "llvm/IR/Value.h" |
20 | | |
21 | | namespace llvm { |
22 | | |
23 | | class Twine; |
24 | | class Module; |
25 | | template <typename ValueSubClass> class SymbolTableListTraits; |
26 | | |
27 | | class GlobalAlias : public GlobalIndirectSymbol, |
28 | | public ilist_node<GlobalAlias> { |
29 | | friend class SymbolTableListTraits<GlobalAlias>; |
30 | | |
31 | | GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, |
32 | | const Twine &Name, Constant *Aliasee, Module *Parent); |
33 | | |
34 | | public: |
35 | | GlobalAlias(const GlobalAlias &) = delete; |
36 | | GlobalAlias &operator=(const GlobalAlias &) = delete; |
37 | | |
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); |
43 | | |
44 | | // Without the Aliasee. |
45 | | static GlobalAlias *create(Type *Ty, unsigned AddressSpace, |
46 | | LinkageTypes Linkage, const Twine &Name, |
47 | | Module *Parent); |
48 | | |
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); |
53 | | |
54 | | // Type, Parent and AddressSpace taken from the Aliasee. |
55 | | static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name, |
56 | | GlobalValue *Aliasee); |
57 | | |
58 | | // Linkage, Type, Parent and AddressSpace taken from the Aliasee. |
59 | | static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee); |
60 | | |
61 | 108 | void copyAttributesFrom(const GlobalValue *Src) { |
62 | 108 | GlobalValue::copyAttributesFrom(Src); |
63 | 108 | } |
64 | | |
65 | | /// removeFromParent - This method unlinks 'this' from the containing module, |
66 | | /// but does not delete it. |
67 | | /// |
68 | | void removeFromParent(); |
69 | | |
70 | | /// eraseFromParent - This method unlinks 'this' from the containing module |
71 | | /// and deletes it. |
72 | | /// |
73 | | void eraseFromParent(); |
74 | | |
75 | | /// These methods retrieve and set alias target. |
76 | | void setAliasee(Constant *Aliasee); |
77 | 10.0k | const Constant *getAliasee() const { |
78 | 10.0k | return getIndirectSymbol(); |
79 | 10.0k | } |
80 | 2.80k | Constant *getAliasee() { |
81 | 2.80k | return getIndirectSymbol(); |
82 | 2.80k | } |
83 | | |
84 | 4.54k | static bool isValidLinkage(LinkageTypes L) { |
85 | 4.54k | return isExternalLinkage(L) || isLocalLinkage(L)1.58k || |
86 | 4.54k | isWeakLinkage(L)1.19k || isLinkOnceLinkage(L)272 ; |
87 | 4.54k | } |
88 | | |
89 | | // Methods for support type inquiry through isa, cast, and dyn_cast: |
90 | 33.2M | static bool classof(const Value *V) { |
91 | 33.2M | return V->getValueID() == Value::GlobalAliasVal; |
92 | 33.2M | } |
93 | | }; |
94 | | |
95 | | } // end namespace llvm |
96 | | |
97 | | #endif // LLVM_IR_GLOBALALIAS_H |