diff options
| author | Gabor Greif <ggreif@gmail.com> | 2009-02-28 22:46:37 +0000 |
|---|---|---|
| committer | Gabor Greif <ggreif@gmail.com> | 2009-02-28 22:46:37 +0000 |
| commit | d07987f5b674bdc9a6ee4fafa266cdb144c15ab9 (patch) | |
| tree | 7422eea143f7257a09f9c38394dc0cd188a6e412 /llvm | |
| parent | faaa7ac1f270bbe463f31064d24ec0203ca1a80d (diff) | |
| download | bcm5719-llvm-d07987f5b674bdc9a6ee4fafa266cdb144c15ab9.tar.gz bcm5719-llvm-d07987f5b674bdc9a6ee4fafa266cdb144c15ab9.zip | |
add description how the ilist_traits<Instruction> works
llvm-svn: 65732
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/BasicBlock.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/include/llvm/BasicBlock.h b/llvm/include/llvm/BasicBlock.h index fdd3ea87d6f..baba18a2387 100644 --- a/llvm/include/llvm/BasicBlock.h +++ b/llvm/include/llvm/BasicBlock.h @@ -25,11 +25,22 @@ class TerminatorInst; 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(); |

