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, bool hasInternalLinkage,
20 const std::string &name = "")
21 : User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {}
23 bool HasInternalLinkage; // Is this value accessable externally?
28 // getType - Global values are always pointers.
29 inline const PointerType *getType() const {
30 return (const PointerType*)User::getType();
33 // Internal Linkage - True if the global value is inaccessible to
34 bool hasInternalLinkage() const { return HasInternalLinkage; }
35 bool hasExternalLinkage() const { return !HasInternalLinkage; }
36 void setInternalLinkage(bool HIL) { HasInternalLinkage = HIL; }
38 // Get the module that this global value is contained inside of...
39 inline Module *getParent() { return Parent; }
40 inline const Module *getParent() const { return Parent; }
42 // Methods for support type inquiry through isa, cast, and dyn_cast:
43 static inline bool classof(const GlobalValue *T) { return true; }
44 static inline bool classof(const Value *V) {
45 return V->getValueType() == Value::MethodVal ||
46 V->getValueType() == Value::GlobalVariableVal;