-//===----------------------------------------------------------------------===//
-// GlobalVariable Implementation
-//===----------------------------------------------------------------------===//
-
-GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link,
- Constant *Initializer,
- const std::string &Name, Module *ParentModule)
- : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name),
- isConstantGlobal(constant) {
- if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
-
- LeakDetector::addGarbageObject(this);
-
- if (ParentModule)
- ParentModule->getGlobalList().push_back(this);
-}
-
-void GlobalVariable::setParent(Module *parent) {
- if (getParent())
- LeakDetector::addGarbageObject(this);
- Parent = parent;
- if (getParent())
- LeakDetector::removeGarbageObject(this);
-}
-
-// Specialize setName to take care of symbol table majik
-void GlobalVariable::setName(const std::string &name, SymbolTable *ST) {
- Module *P;
- assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) &&
- "Invalid symtab argument!");
- if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this);
- Value::setName(name);
- if (P && hasName()) P->getSymbolTable().insert(this);
-}