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 Function. 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"
17 class GlobalValue : public User {
18 GlobalValue(const GlobalValue &); // do not implement
20 GlobalValue(const Type *Ty, ValueTy vty, bool hasInternalLinkage,
21 const std::string &name = "")
22 : User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {}
24 bool HasInternalLinkage; // Is this value accessable externally?
29 /// getType - Global values are always pointers.
30 inline const PointerType *getType() const {
31 return (const PointerType*)User::getType();
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; }
39 /// isExternal - Return true if the primary definition of this global value is
40 /// outside of the current translation unit...
41 virtual bool isExternal() const = 0;
43 /// getParent - Get the module that this global value is contained inside
45 inline Module *getParent() { return Parent; }
46 inline const Module *getParent() const { return Parent; }
48 // Methods for support type inquiry through isa, cast, and dyn_cast:
49 static inline bool classof(const GlobalValue *T) { return true; }
50 static inline bool classof(const Value *V) {
51 return V->getValueType() == Value::FunctionVal ||
52 V->getValueType() == Value::GlobalVariableVal;