diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index fdd3ea87d6f..baba18a2387 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -25,11 +25,22 @@ class TerminatorInst; template<> struct ilist_traits : public SymbolTableListTraits { - // createSentinel is used to create a node that marks the end of the list... + // createSentinel is used to get hold of a node that marks the end of + // the list... + // The sentinel is relative to this instance, so we use a non-static + // method. Instruction *createSentinel() const { + // since i(p)lists always publicly derive from the corresponding + // traits, placing a data member in this class will augment i(p)list. + // But since the NodeTy is expected to publicly derive from + // ilist_node, there is a legal viable downcast from it + // to NodeTy. We use this trick to superpose i(p)list with a "ghostly" + // NodeTy, which becomes the sentinel. Dereferencing the sentinel is + // forbidden (save the ilist_node) so noone will ever notice + // the superposition. return const_cast(static_cast(&Sentinel)); } - static void destroySentinel(Instruction *I) { I = I; } + static void destroySentinel(Instruction*) {} static iplist &getList(BasicBlock *BB); static ValueSymbolTable *getSymTab(BasicBlock *ItemParent); static int getListOffset();