LLVM API Documentation
#include <GlobalVariable.h>
Inheritance diagram for llvm::GlobalVariable:
Public Member Functions | |
GlobalVariable (const Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=0, const std::string &Name="", Module *Parent=0) | |
virtual bool | isExternal () const |
bool | hasInitializer () const |
Constant * | getInitializer () const |
Constant * | getInitializer () |
void | setInitializer (Constant *CPV) |
GlobalVariable * | getNext () |
const GlobalVariable * | getNext () const |
GlobalVariable * | getPrev () |
const GlobalVariable * | getPrev () const |
bool | isConstant () const |
void | setConstant (bool Value) |
void | removeFromParent () |
void | eraseFromParent () |
virtual void | replaceUsesOfWithOnConstant (Value *From, Value *To, Use *U) |
virtual void | print (std::ostream &OS) const |
Static Public Member Functions | |
static bool | classof (const GlobalVariable *) |
static bool | classof (const Value *V) |
Friends | |
class | SymbolTableListTraits< GlobalVariable, Module, Module,ilist_traits< GlobalVariable > > |
Definition at line 34 of file GlobalVariable.h.
GlobalVariable::GlobalVariable | ( | const Type * | Ty, | |
bool | isConstant, | |||
LinkageTypes | Linkage, | |||
Constant * | Initializer = 0 , |
|||
const std::string & | Name = "" , |
|||
Module * | Parent = 0 | |||
) |
GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the end of the specified modules global list.
Definition at line 74 of file Globals.cpp.
References llvm::LeakDetector::addGarbageObject(), llvm::Module::getGlobalList(), llvm::Value::getType(), and llvm::Use::init().
static bool llvm::GlobalVariable::classof | ( | const Value * | V | ) | [inline, static] |
Reimplemented from llvm::GlobalValue.
Definition at line 125 of file GlobalVariable.h.
References llvm::Value::GlobalVariableVal, and V.
static bool llvm::GlobalVariable::classof | ( | const GlobalVariable * | ) | [inline, static] |
Definition at line 124 of file GlobalVariable.h.
void GlobalVariable::eraseFromParent | ( | ) |
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition at line 106 of file Globals.cpp.
References llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().
Referenced by InstallGlobalCtors(), and LinkGlobals().
Constant* llvm::GlobalVariable::getInitializer | ( | ) | [inline] |
Constant* llvm::GlobalVariable::getInitializer | ( | ) | const [inline] |
getInitializer - Return the initializer for this global variable. It is illegal to call this method if the global is external, because we cannot tell what the value is initialized to!
Definition at line 73 of file GlobalVariable.h.
References llvm::Use::get(), and hasInitializer().
Referenced by llvm::ProgramInfo::getFunction(), llvm::ProgramInfo::getSourceFile(), InstallGlobalCtors(), LinkAppendingVars(), LinkGlobalInits(), and llvm::SourceFunctionInfo::SourceFunctionInfo().
const GlobalVariable* llvm::GlobalVariable::getNext | ( | ) | const [inline] |
GlobalVariable* llvm::GlobalVariable::getNext | ( | ) | [inline] |
const GlobalVariable* llvm::GlobalVariable::getPrev | ( | ) | const [inline] |
GlobalVariable* llvm::GlobalVariable::getPrev | ( | ) | [inline] |
bool llvm::GlobalVariable::hasInitializer | ( | ) | const [inline] |
hasInitializer - Unless a global variable isExternal(), it has an initializer. The initializer for the global variable/constant is held by Initializer if an initializer is specified.
Definition at line 67 of file GlobalVariable.h.
References isExternal().
Referenced by llvm::ProgramInfo::getFunction(), getInitializer(), llvm::ProgramInfo::getSourceFile(), LinkGlobalInits(), setInitializer(), and llvm::SourceFunctionInfo::SourceFunctionInfo().
bool llvm::GlobalVariable::isConstant | ( | ) | const [inline] |
If the value is a global constant, its value is immutable throughout the runtime execution of the program. Assigning a value into the constant leads to undefined behavior.
Definition at line 104 of file GlobalVariable.h.
Referenced by InstallGlobalCtors(), LinkAppendingVars(), and LinkGlobals().
virtual bool llvm::GlobalVariable::isExternal | ( | ) | const [inline, virtual] |
isExternal - Is this global variable lacking an initializer? If so, the global variable is defined in some other translation unit, and is thus externally defined here.
Implements llvm::GlobalValue.
Definition at line 61 of file GlobalVariable.h.
References llvm::User::getNumOperands().
Referenced by hasInitializer(), and LinkGlobals().
void GlobalVariable::print | ( | std::ostream & | OS | ) | const [virtual] |
print - Implement operator<< on Value...
Reimplemented from llvm::Constant.
Definition at line 1279 of file AsmWriter.cpp.
References llvm::GlobalValue::getParent(), and llvm::AssemblyWriter::write().
void GlobalVariable::removeFromParent | ( | ) |
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition at line 102 of file Globals.cpp.
References llvm::Module::getGlobalList(), and llvm::GlobalValue::getParent().
Override Constant's implementation of this method so we can replace constant initializers.
Reimplemented from llvm::Constant.
Definition at line 110 of file Globals.cpp.
References llvm::User::getNumOperands(), llvm::Constant::getOperand(), and llvm::Constant::setOperand().
void llvm::GlobalVariable::setConstant | ( | bool | Value | ) | [inline] |
void llvm::GlobalVariable::setInitializer | ( | Constant * | CPV | ) | [inline] |
Definition at line 81 of file GlobalVariable.h.
References hasInitializer(), llvm::User::NumOperands, and llvm::Use::set().
Referenced by InstallGlobalCtors(), LinkAppendingVars(), LinkGlobalInits(), LinkGlobals(), and ProcessGlobalsWithSameName().
friend class SymbolTableListTraits< GlobalVariable, Module, Module,ilist_traits< GlobalVariable > > [friend] |
Definition at line 36 of file GlobalVariable.h.