diff --git a/include/llvm/Function.h b/include/llvm/Function.h index ee53252b954..bdae9cd02f5 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -32,12 +32,17 @@ class FunctionType; template<> struct ilist_traits : public SymbolTableListTraits { - // createSentinel is used to create a node that marks the end of the list... - static BasicBlock *createSentinel(); - static void destroySentinel(BasicBlock *BB) { delete BB; } + // createSentinel is used to get hold of the node that marks the end of the + // list... (same trick used here as in ilist_traits) + BasicBlock *createSentinel() const { + return const_cast(static_cast(&Sentinel)); + } + static void destroySentinel(BasicBlock*) {} static iplist &getList(Function *F); static ValueSymbolTable *getSymTab(Function *ItemParent); static int getListOffset(); +private: + ilist_node Sentinel; }; template<> struct ilist_traits diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index cff4457a418..fefe082cb4e 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -22,13 +22,6 @@ #include "llvm/ADT/StringExtras.h" using namespace llvm; -BasicBlock *ilist_traits::createSentinel() { - BasicBlock *Ret = BasicBlock::Create(); - // This should not be garbage monitored. - LeakDetector::removeGarbageObject(Ret); - return Ret; -} - iplist &ilist_traits::getList(Function *F) { return F->getBasicBlockList(); }