Add a forward defn for Module since it's no longer in Value.h
[oota-llvm.git] / include / llvm / GlobalValue.h
1 //===-- llvm/GlobalValue.h - Class to represent a global value ---*- C++ -*--=//
2 //
3 // This file is a common base class of all globally definable objects.  As such,
4 // it is subclassed by GlobalVariable and by Method.  This is used because you
5 // can do certain things with these global objects that you can't do to anything
6 // else.  For example, use the address of one as a constant.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_GLOBALVALUE_H
11 #define LLVM_GLOBALVALUE_H
12
13 #include "llvm/User.h"
14 class PointerType;
15 class Module;
16
17 class GlobalValue : public User {
18   GlobalValue(const GlobalValue &);             // do not implement
19 protected:
20   GlobalValue(const Type *Ty, ValueTy vty, bool hasInternalLinkage,
21               const std::string &name = "")
22     : User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {}
23
24   bool HasInternalLinkage;    // Is this value accessable externally?
25   Module *Parent;
26 public:
27   ~GlobalValue() {}
28
29   // getType - Global values are always pointers.
30   inline const PointerType *getType() const {
31     return (const PointerType*)User::getType();
32   }
33
34   // Internal Linkage - True if the global value is inaccessible to 
35   bool hasInternalLinkage() const { return HasInternalLinkage; }
36   bool hasExternalLinkage() const { return !HasInternalLinkage; }
37   void setInternalLinkage(bool HIL) { HasInternalLinkage = HIL; }
38
39   // Get the module that this global value is contained inside of...
40   inline Module *getParent() { return Parent; }
41   inline const Module *getParent() const { return Parent; }
42
43   // Methods for support type inquiry through isa, cast, and dyn_cast:
44   static inline bool classof(const GlobalValue *T) { return true; }
45   static inline bool classof(const Value *V) {
46     return V->getValueType() == Value::FunctionVal || 
47            V->getValueType() == Value::GlobalVariableVal;
48   }
49 };
50
51 #endif