1 //===-- llvm/GlobalValue.h - Class to represent a global value ---*- C++ -*--=//
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.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_GLOBALVALUE_H
11 #define LLVM_GLOBALVALUE_H
13 #include "llvm/User.h"
16 class GlobalValue : public User {
17 GlobalValue(const GlobalValue &); // do not implement
19 GlobalValue(const Type *Ty, ValueTy vty, const string &name = "")
20 : User(Ty, vty, name) { Parent = 0; }
26 // getType - Global values are always pointers.
27 inline const PointerType *getType() const {
28 return (const PointerType*)User::getType();
31 // Get the module that this global value is contained inside of...
32 inline Module *getParent() { return Parent; }
33 inline const Module *getParent() const { return Parent; }
35 // Methods for support type inquiry through isa, cast, and dyn_cast:
36 static inline bool classof(const GlobalValue *T) { return true; }
37 static inline bool classof(const Value *V) {
38 return V->getValueType() == Value::MethodVal ||
39 V->getValueType() == Value::GlobalVariableVal;