aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/Function.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-06-25 16:13:24 +0000
committerChris Lattner <sabre@nondot.org>2002-06-25 16:13:24 +0000
commit7e70829632f82de15db187845666aaca6e04b792 (patch)
tree48dd2d804e7ebec9a3cbd8bf229cb2a2aa20dce5 /lib/VMCore/Function.cpp
parent0b12b5f50ec77a8bd01b92d287c52d748619bb4b (diff)
MEGAPATCH checkin.
For details, See: docs/2002-06-25-MegaPatchInfo.txt git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2779 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Function.cpp')
-rw-r--r--lib/VMCore/Function.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp
index a91948f31c..f7d7953aab 100644
--- a/lib/VMCore/Function.cpp
+++ b/lib/VMCore/Function.cpp
@@ -12,7 +12,24 @@
#include "llvm/BasicBlock.h"
#include "llvm/iOther.h"
#include "llvm/Argument.h"
-#include "ValueHolderImpl.h"
+#include "SymbolTableListTraitsImpl.h"
+
+iplist<BasicBlock> &ilist_traits<BasicBlock>::getList(Function *F) {
+ return F->getBasicBlockList();
+}
+
+Argument *ilist_traits<Argument>::createNode() {
+ return new Argument(Type::IntTy);
+}
+
+iplist<Argument> &ilist_traits<Argument>::getList(Function *F) {
+ return F->getArgumentList();
+}
+
+// Explicit instantiations of SymbolTableListTraits since some of the methods
+// are not in the public header file...
+template SymbolTableListTraits<Argument, Function, Function>;
+template SymbolTableListTraits<BasicBlock, Function, Function>;
//===----------------------------------------------------------------------===//
// Argument Implementation
@@ -28,36 +45,28 @@ void Argument::setName(const std::string &name, SymbolTable *ST) {
if (P && hasName()) P->getSymbolTable()->insert(this);
}
-
-
//===----------------------------------------------------------------------===//
// Function Implementation
//===----------------------------------------------------------------------===//
-// Instantiate Templates - This ugliness is the price we have to pay
-// for having a ValueHolderImpl.h file seperate from ValueHolder.h! :(
-//
-template class ValueHolder<Argument , Function, Function>;
-template class ValueHolder<BasicBlock, Function, Function>;
-
Function::Function(const FunctionType *Ty, bool isInternal,
const std::string &name)
- : GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name),
- BasicBlocks(this), ArgumentList(this, this) {
+ : GlobalValue(PointerType::get(Ty), Value::FunctionVal, isInternal, name) {
+ BasicBlocks.setItemParent(this);
+ BasicBlocks.setParent(this);
+ ArgumentList.setItemParent(this);
+ ArgumentList.setParent(this);
ParentSymTab = SymTab = 0;
}
Function::~Function() {
dropAllReferences(); // After this it is safe to delete instructions.
- // TODO: Should remove from the end, not the beginning of vector!
- iterator BI = begin();
- while ((BI = begin()) != end())
- delete BasicBlocks.remove(BI);
+ BasicBlocks.clear(); // Delete all basic blocks...
// Delete all of the method arguments and unlink from symbol table...
- ArgumentList.delete_all();
+ ArgumentList.clear();
ArgumentList.setParent(0);
delete SymTab;
}
@@ -118,7 +127,8 @@ bool Function::hasSymbolTable() const {
// delete.
//
void Function::dropAllReferences() {
- for_each(begin(), end(), std::mem_fun(&BasicBlock::dropAllReferences));
+ for (iterator I = begin(), E = end(); I != E; ++I)
+ I->dropAllReferences();
}
//===----------------------------------------------------------------------===//