/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/include/llvm/IR/GlobalAlias.h
Line | Count | Source |
1 | | //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | // |
10 | | // This file contains the declaration of the GlobalAlias class, which |
11 | | // represents a single function or variable alias in the IR. |
12 | | // |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_IR_GLOBALALIAS_H |
16 | | #define LLVM_IR_GLOBALALIAS_H |
17 | | |
18 | | #include "llvm/ADT/ilist_node.h" |
19 | | #include "llvm/IR/GlobalIndirectSymbol.h" |
20 | | #include "llvm/IR/Value.h" |
21 | | |
22 | | namespace llvm { |
23 | | |
24 | | class Twine; |
25 | | class Module; |
26 | | template <typename ValueSubClass> class SymbolTableListTraits; |
27 | | |
28 | | class GlobalAlias : public GlobalIndirectSymbol, |
29 | | public ilist_node<GlobalAlias> { |
30 | | friend class SymbolTableListTraits<GlobalAlias>; |
31 | | |
32 | | GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, |
33 | | const Twine &Name, Constant *Aliasee, Module *Parent); |
34 | | |
35 | | public: |
36 | | GlobalAlias(const GlobalAlias &) = delete; |
37 | | GlobalAlias &operator=(const GlobalAlias &) = delete; |
38 | | |
39 | | /// If a parent module is specified, the alias is automatically inserted into |
40 | | /// the end of the specified module's alias list. |
41 | | static GlobalAlias *create(Type *Ty, unsigned AddressSpace, |
42 | | LinkageTypes Linkage, const Twine &Name, |
43 | | Constant *Aliasee, Module *Parent); |
44 | | |
45 | | // Without the Aliasee. |
46 | | static GlobalAlias *create(Type *Ty, unsigned AddressSpace, |
47 | | LinkageTypes Linkage, const Twine &Name, |
48 | | Module *Parent); |
49 | | |
50 | | // The module is taken from the Aliasee. |
51 | | static GlobalAlias *create(Type *Ty, unsigned AddressSpace, |
52 | | LinkageTypes Linkage, const Twine &Name, |
53 | | GlobalValue *Aliasee); |
54 | | |
55 | | // Type, Parent and AddressSpace taken from the Aliasee. |
56 | | static GlobalAlias *create(LinkageTypes Linkage, const Twine &Name, |
57 | | GlobalValue *Aliasee); |
58 | | |
59 | | // Linkage, Type, Parent and AddressSpace taken from the Aliasee. |
60 | | static GlobalAlias *create(const Twine &Name, GlobalValue *Aliasee); |
61 | | |
62 | 98 | void copyAttributesFrom(const GlobalValue *Src) { |
63 | 98 | GlobalValue::copyAttributesFrom(Src); |
64 | 98 | } |
65 | | |
66 | | /// removeFromParent - This method unlinks 'this' from the containing module, |
67 | | /// but does not delete it. |
68 | | /// |
69 | | void removeFromParent(); |
70 | | |
71 | | /// eraseFromParent - This method unlinks 'this' from the containing module |
72 | | /// and deletes it. |
73 | | /// |
74 | | void eraseFromParent(); |
75 | | |
76 | | /// These methods retrieve and set alias target. |
77 | | void setAliasee(Constant *Aliasee); |
78 | 7.55k | const Constant *getAliasee() const { |
79 | 7.55k | return getIndirectSymbol(); |
80 | 7.55k | } |
81 | 1.10k | Constant *getAliasee() { |
82 | 1.10k | return getIndirectSymbol(); |
83 | 1.10k | } |
84 | | |
85 | 3.41k | static bool isValidLinkage(LinkageTypes L) { |
86 | 1.30k | return isExternalLinkage(L) || isLocalLinkage(L) || |
87 | 3.41k | isWeakLinkage(L)986 || isLinkOnceLinkage(L)341 ; |
88 | 3.41k | } |
89 | | |
90 | | // Methods for support type inquiry through isa, cast, and dyn_cast: |
91 | 47.7M | static bool classof(const Value *V) { |
92 | 47.7M | return V->getValueID() == Value::GlobalAliasVal; |
93 | 47.7M | } |
94 | | }; |
95 | | |
96 | | } // end namespace llvm |
97 | | |
98 | | #endif // LLVM_IR_GLOBALALIAS_H |