Declare Sentinel fragments as mutable to get rid

of some pointless casting. This fragment logically
does not belong to ilist anyway, but to "ghostly"
NodeType.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65843 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Gabor Greif 2009-03-02 14:47:45 +00:00
parent 5b78a7cabe
commit 1012919ed8
2 changed files with 6 additions and 6 deletions

View File

@ -38,14 +38,14 @@ template<> struct ilist_traits<Instruction>
// NodeTy, which becomes the sentinel. Dereferencing the sentinel is // NodeTy, which becomes the sentinel. Dereferencing the sentinel is
// forbidden (save the ilist_node<NodeTy>) so no one will ever notice // forbidden (save the ilist_node<NodeTy>) so no one will ever notice
// the superposition. // the superposition.
return const_cast<Instruction*>(static_cast<const Instruction*>(&Sentinel)); return static_cast<Instruction*>(&Sentinel);
} }
static void destroySentinel(Instruction*) {} static void destroySentinel(Instruction*) {}
static iplist<Instruction> &getList(BasicBlock *BB); static iplist<Instruction> &getList(BasicBlock *BB);
static ValueSymbolTable *getSymTab(BasicBlock *ItemParent); static ValueSymbolTable *getSymTab(BasicBlock *ItemParent);
static int getListOffset(); static int getListOffset();
private: private:
ilist_node<Instruction> Sentinel; mutable ilist_node<Instruction> Sentinel;
}; };
/// This represents a single basic block in LLVM. A basic block is simply a /// This represents a single basic block in LLVM. A basic block is simply a

View File

@ -35,28 +35,28 @@ template<> struct ilist_traits<BasicBlock>
// createSentinel is used to get hold of the node that marks the end of the // createSentinel is used to get hold of the node that marks the end of the
// list... (same trick used here as in ilist_traits<Instruction>) // list... (same trick used here as in ilist_traits<Instruction>)
BasicBlock *createSentinel() const { BasicBlock *createSentinel() const {
return const_cast<BasicBlock*>(static_cast<const BasicBlock*>(&Sentinel)); return static_cast<BasicBlock*>(&Sentinel);
} }
static void destroySentinel(BasicBlock*) {} static void destroySentinel(BasicBlock*) {}
static iplist<BasicBlock> &getList(Function *F); static iplist<BasicBlock> &getList(Function *F);
static ValueSymbolTable *getSymTab(Function *ItemParent); static ValueSymbolTable *getSymTab(Function *ItemParent);
static int getListOffset(); static int getListOffset();
private: private:
ilist_node<BasicBlock> Sentinel; mutable ilist_node<BasicBlock> Sentinel;
}; };
template<> struct ilist_traits<Argument> template<> struct ilist_traits<Argument>
: public SymbolTableListTraits<Argument, Function> { : public SymbolTableListTraits<Argument, Function> {
Argument *createSentinel() const { Argument *createSentinel() const {
return const_cast<Argument*>(static_cast<const Argument*>(&Sentinel)); return static_cast<Argument*>(&Sentinel);
} }
static void destroySentinel(Argument*) {} static void destroySentinel(Argument*) {}
static iplist<Argument> &getList(Function *F); static iplist<Argument> &getList(Function *F);
static ValueSymbolTable *getSymTab(Function *ItemParent); static ValueSymbolTable *getSymTab(Function *ItemParent);
static int getListOffset(); static int getListOffset();
private: private:
ilist_node<Argument> Sentinel; mutable ilist_node<Argument> Sentinel;
}; };
class Function : public GlobalValue, public Annotable, class Function : public GlobalValue, public Annotable,