[llvm-commits] [llvm] r65732 - /llvm/trunk/include/llvm/BasicBlock.h
Gabor Greif
ggreif at gmail.com
Sat Feb 28 14:46:37 PST 2009
Author: ggreif
Date: Sat Feb 28 16:46:37 2009
New Revision: 65732
URL: http://llvm.org/viewvc/llvm-project?rev=65732&view=rev
Log:
add description how the ilist_traits<Instruction> works
Modified:
llvm/trunk/include/llvm/BasicBlock.h
Modified: llvm/trunk/include/llvm/BasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BasicBlock.h?rev=65732&r1=65731&r2=65732&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BasicBlock.h (original)
+++ llvm/trunk/include/llvm/BasicBlock.h Sat Feb 28 16:46:37 2009
@@ -25,11 +25,22 @@
template<> struct ilist_traits<Instruction>
: public SymbolTableListTraits<Instruction, BasicBlock> {
- // 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<NodeTy>, 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<NodeTy>) so noone will ever notice
+ // the superposition.
return const_cast<Instruction*>(static_cast<const Instruction*>(&Sentinel));
}
- static void destroySentinel(Instruction *I) { I = I; }
+ static void destroySentinel(Instruction*) {}
static iplist<Instruction> &getList(BasicBlock *BB);
static ValueSymbolTable *getSymTab(BasicBlock *ItemParent);
static int getListOffset();
More information about the llvm-commits
mailing list