LLVM  6.0.0svn
GlobalAlias.h
Go to the documentation of this file.
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"
20 #include "llvm/IR/Value.h"
21 
22 namespace llvm {
23 
24 class Twine;
25 class Module;
26 template <typename ValueSubClass> class SymbolTableListTraits;
27 
29  public ilist_node<GlobalAlias> {
31 
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,
43  Constant *Aliasee, Module *Parent);
44 
45  // Without the Aliasee.
46  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
48  Module *Parent);
49 
50  // The module is taken from the Aliasee.
51  static GlobalAlias *create(Type *Ty, unsigned AddressSpace,
53  GlobalValue *Aliasee);
54 
55  // Type, Parent and AddressSpace taken from the Aliasee.
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  void copyAttributesFrom(const GlobalValue *Src) {
64  }
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  const Constant *getAliasee() const {
79  return getIndirectSymbol();
80  }
82  return getIndirectSymbol();
83  }
84 
85  static bool isValidLinkage(LinkageTypes L) {
86  return isExternalLinkage(L) || isLocalLinkage(L) ||
88  }
89 
90  // Methods for support type inquiry through isa, cast, and dyn_cast:
91  static bool classof(const Value *V) {
92  return V->getValueID() == Value::GlobalAliasVal;
93  }
94 };
95 
96 } // end namespace llvm
97 
98 #endif // LLVM_IR_GLOBALALIAS_H
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Definition: Globals.cpp:66
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:465
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:282
GlobalAlias & operator=(const GlobalAlias &)=delete
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:312
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:291
Constant * getAliasee()
Definition: GlobalAlias.h:81
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:433
static bool classof(const Value *V)
Definition: GlobalAlias.h:91
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
void copyAttributesFrom(const GlobalValue *Src)
Definition: GlobalAlias.h:62
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This is an important base class in LLVM.
Definition: Constant.h:42
static bool isValidLinkage(LinkageTypes L)
Definition: GlobalAlias.h:85
static bool isWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:300
AddressSpace
Definition: NVPTXBaseInfo.h:22
unsigned Linkage
Definition: GlobalValue.h:94
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:48
void removeFromParent()
removeFromParent - This method unlinks &#39;this&#39; from the containing module, but does not delete it...
Definition: Globals.cpp:429
const Constant * getIndirectSymbol() const
LLVM Value Representation.
Definition: Value.h:73
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
Definition: Globals.cpp:400
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:437
const Constant * getAliasee() const
Definition: GlobalAlias.h:78