From 1012919ed8b3e2cd4b421c104ce9d8f4e20ced9d Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Mon, 2 Mar 2009 14:47:45 +0000 Subject: [PATCH] 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 --- include/llvm/BasicBlock.h | 4 ++-- include/llvm/Function.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 3ef83e8a816..54f3690096e 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -38,14 +38,14 @@ template<> struct ilist_traits // NodeTy, which becomes the sentinel. Dereferencing the sentinel is // forbidden (save the ilist_node) so no one will ever notice // the superposition. - return const_cast(static_cast(&Sentinel)); + return static_cast(&Sentinel); } static void destroySentinel(Instruction*) {} static iplist &getList(BasicBlock *BB); static ValueSymbolTable *getSymTab(BasicBlock *ItemParent); static int getListOffset(); private: - ilist_node Sentinel; + mutable ilist_node Sentinel; }; /// This represents a single basic block in LLVM. A basic block is simply a diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 9f4f23be088..37e8f19f625 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -35,28 +35,28 @@ template<> struct ilist_traits // createSentinel is used to get hold of the node that marks the end of the // list... (same trick used here as in ilist_traits) BasicBlock *createSentinel() const { - return const_cast(static_cast(&Sentinel)); + return static_cast(&Sentinel); } static void destroySentinel(BasicBlock*) {} static iplist &getList(Function *F); static ValueSymbolTable *getSymTab(Function *ItemParent); static int getListOffset(); private: - ilist_node Sentinel; + mutable ilist_node Sentinel; }; template<> struct ilist_traits : public SymbolTableListTraits { Argument *createSentinel() const { - return const_cast(static_cast(&Sentinel)); + return static_cast(&Sentinel); } static void destroySentinel(Argument*) {} static iplist &getList(Function *F); static ValueSymbolTable *getSymTab(Function *ItemParent); static int getListOffset(); private: - ilist_node Sentinel; + mutable ilist_node Sentinel; }; class Function : public GlobalValue, public Annotable,