* Both Method & GlobalVariable now subclass GlobalValue
[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
16 class GlobalValue : public User {
17   GlobalValue(const GlobalValue &);             // do not implement
18 protected:
19   GlobalValue(const Type *Ty, ValueTy vty, const string &name = "")
20     : User(Ty, vty, name) {}
21 public:
22
23   // getType - Global values are always pointers (FIXME, methods should be ptrs too!)
24   inline const PointerType *getType() const {
25     return (const PointerType*)User::getType();
26   }
27
28   // Methods for support type inquiry through isa, cast, and dyn_cast:
29   static inline bool classof(const GlobalValue *T) { return true; }
30   static inline bool classof(const Value *V) {
31     return V->getValueType() == Value::MethodVal || 
32            V->getValueType() == Value::GlobalVariableVal;
33   }
34 };
35
36 #endif