1 //===______-- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Anton Korobeynikov and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declaration of the GlobalAlias class, which
11 // represents a single function or variable alias in the VM.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_GLOBAL_ALIAS_H
16 #define LLVM_GLOBAL_ALIAS_H
18 #include "llvm/GlobalValue.h"
25 template<typename ValueSubClass, typename ItemParentClass>
26 class SymbolTableListTraits;
28 class GlobalAlias : public GlobalValue {
29 friend class SymbolTableListTraits<GlobalAlias, Module>;
30 void operator=(const GlobalAlias &); // Do not implement
31 GlobalAlias(const GlobalAlias &); // Do not implement
33 void setParent(Module *parent);
35 GlobalAlias *Prev, *Next;
36 void setNext(GlobalAlias *N) { Next = N; }
37 void setPrev(GlobalAlias *N) { Prev = N; }
39 const GlobalValue* Aliasee;
42 /// GlobalAlias ctor - If a parent module is specified, the alias is
43 /// automatically inserted into the end of the specified modules alias list.
44 GlobalAlias(const Type *Ty, LinkageTypes Linkage, const std::string &Name = "",
45 const GlobalValue* Aliasee = 0, Module *Parent = 0);
47 /// isDeclaration - Is this global variable lacking an initializer? If so,
48 /// the global variable is defined in some other translation unit, and is thus
49 /// only a declaration here.
50 virtual bool isDeclaration() const;
52 /// removeFromParent - This method unlinks 'this' from the containing module,
53 /// but does not delete it.
55 virtual void removeFromParent();
57 /// eraseFromParent - This method unlinks 'this' from the containing module
60 virtual void eraseFromParent();
62 virtual void print(std::ostream &OS) const;
63 void print(std::ostream *OS) const { if (OS) print(*OS); }
65 void setAliasee(const GlobalValue* GV);
66 const GlobalValue* getAliasee() const { return Aliasee; }
68 // Methods for support type inquiry through isa, cast, and dyn_cast:
69 static inline bool classof(const GlobalAlias *) { return true; }
70 static inline bool classof(const Value *V) {
71 return V->getValueID() == Value::GlobalAliasVal;
74 // getNext/Prev - Return the next or previous alias in the list.
75 GlobalAlias *getNext() { return Next; }
76 const GlobalAlias *getNext() const { return Next; }
77 GlobalAlias *getPrev() { return Prev; }
78 const GlobalAlias *getPrev() const { return Prev; }
81 } // End llvm namespace