+
+//===----------------------------------------------------------------------===//
+// Function Implementation
+//===----------------------------------------------------------------------===//
+
+Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
+ const std::string &name, Module *ParentModule)
+ : GlobalValue(PointerType::get(Ty), Value::FunctionVal, Linkage, name) {
+ BasicBlocks.setItemParent(this);
+ BasicBlocks.setParent(this);
+ ArgumentList.setItemParent(this);
+ ArgumentList.setParent(this);
+ SymTab = new SymbolTable();
+
+ // Create the arguments vector, all arguments start out unnamed.
+ for (unsigned i = 0, e = Ty->getNumParams(); i != e; ++i) {
+ assert(Ty->getParamType(i) != Type::VoidTy &&
+ "Cannot have void typed arguments!");
+ ArgumentList.push_back(new Argument(Ty->getParamType(i)));
+ }
+
+ // Make sure that we get added to a function
+ LeakDetector::addGarbageObject(this);
+
+ if (ParentModule)
+ ParentModule->getFunctionList().push_back(this);
+}
+
+Function::~Function() {