-// Instantiate Templates - This ugliness is the price we have to pay
-// for having a ValueHolderImpl.h file seperate from ValueHolder.h! :(
-//
-template class ValueHolder<MethodArgument, Method, Method>;
-template class ValueHolder<BasicBlock , Method, Method>;
+ // Make sure that we get added to a function
+ LeakDetector::addGarbageObject(this);
+
+ if (Par)
+ Par->getArgumentList().push_back(this);
+}
+
+
+// Specialize setName to take care of symbol table majik
+void Argument::setName(const std::string &name, SymbolTable *ST) {
+ Function *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);
+}
+
+void Argument::setParent(Function *parent) {
+ if (getParent())
+ LeakDetector::addGarbageObject(this);
+ Parent = parent;
+ if (getParent())
+ LeakDetector::removeGarbageObject(this);
+}
+
+
+//===----------------------------------------------------------------------===//
+// Function Implementation
+//===----------------------------------------------------------------------===//
+
+Function::Function(const FunctionType *Ty, bool isInternal,
+ const std::string &name, Module *ParentModule)
+ : GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name) {
+ BasicBlocks.setItemParent(this);
+ BasicBlocks.setParent(this);
+ ArgumentList.setItemParent(this);
+ ArgumentList.setParent(this);
+ ParentSymTab = SymTab = 0;
+
+ // Make sure that we get added to a function
+ LeakDetector::addGarbageObject(this);