Fix for PR1801
[llvm-complete.git] / include / llvm / GlobalAlias.h
blobbbd19ba8816d802e8b382bdf462b93b949b31ec2
1 //===-------- llvm/GlobalAlias.h - GlobalAlias class ------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
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.
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.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_GLOBAL_ALIAS_H
16 #define LLVM_GLOBAL_ALIAS_H
18 #include "llvm/GlobalValue.h"
20 namespace llvm {
22 class Module;
23 class Constant;
24 class PointerType;
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 // getNext/Prev - Return the next or previous alias in the list.
40 GlobalAlias *getNext() { return Next; }
41 const GlobalAlias *getNext() const { return Next; }
42 GlobalAlias *getPrev() { return Prev; }
43 const GlobalAlias *getPrev() const { return Prev; }
45 Use Aliasee;
46 public:
47 /// GlobalAlias ctor - If a parent module is specified, the alias is
48 /// automatically inserted into the end of the specified module's alias list.
49 GlobalAlias(const Type *Ty, LinkageTypes Linkage, const std::string &Name = "",
50 Constant* Aliasee = 0, Module *Parent = 0);
52 /// isDeclaration - Is this global variable lacking an initializer? If so,
53 /// the global variable is defined in some other translation unit, and is thus
54 /// only a declaration here.
55 virtual bool isDeclaration() const;
57 /// removeFromParent - This method unlinks 'this' from the containing module,
58 /// but does not delete it.
59 ///
60 void removeFromParent();
62 /// eraseFromParent - This method unlinks 'this' from the containing module
63 /// and deletes it.
64 ///
65 void eraseFromParent();
67 virtual void print(std::ostream &OS) const;
68 void print(std::ostream *OS) const { if (OS) print(*OS); }
70 /// set/getAliasee - These methods retrive and set alias target.
71 void setAliasee(Constant* GV);
72 const Constant* getAliasee() const {
73 return cast_or_null<Constant>(getOperand(0));
75 Constant* getAliasee() {
76 return cast_or_null<Constant>(getOperand(0));
78 /// getAliasedGlobal() - Aliasee can be either global or bitcast of
79 /// global. This method retrives the global for both aliasee flavours.
80 const GlobalValue* getAliasedGlobal() const;
82 // Methods for support type inquiry through isa, cast, and dyn_cast:
83 static inline bool classof(const GlobalAlias *) { return true; }
84 static inline bool classof(const Value *V) {
85 return V->getValueID() == Value::GlobalAliasVal;
89 } // End llvm namespace
91 #endif