+#include "llvm/SymbolTable.h"
+#include "Support/LeakDetector.h"
+#include "SymbolTableListTraitsImpl.h"
+#include <algorithm>
+
+// DummyInst - An instance of this class is used to mark the end of the
+// instruction list. This is not a real instruction.
+//
+struct DummyInst : public Instruction {
+ DummyInst() : Instruction(Type::VoidTy, NumOtherOps) {
+ // This should not be garbage monitored.
+ LeakDetector::removeGarbageObject(this);
+ }
+
+ virtual Instruction *clone() const {
+ assert(0 && "Cannot clone EOL");abort();
+ return 0;
+ }
+ virtual const char *getOpcodeName() const { return "*end-of-list-inst*"; }
+
+ // Methods for support type inquiry through isa, cast, and dyn_cast...
+ static inline bool classof(const DummyInst *) { return true; }
+ static inline bool classof(const Instruction *I) {
+ return I->getOpcode() == NumOtherOps;
+ }
+ static inline bool classof(const Value *V) {
+ return isa<Instruction>(V) && classof(cast<Instruction>(V));
+ }
+};
+
+Instruction *ilist_traits<Instruction>::createNode() {
+ return new DummyInst();
+}
+iplist<Instruction> &ilist_traits<Instruction>::getList(BasicBlock *BB) {
+ return BB->getInstList();
+}
+
+// Explicit instantiation of SymbolTableListTraits since some of the methods
+// are not in the public header file...
+template SymbolTableListTraits<Instruction, BasicBlock, Function>;