X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSymbolTableListTraits.h;h=91a4eb99ff0d368c489c7b0d9ff50829b93bf08a;hb=d8c5ec6aece5732c766bd7d773ff75976d364168;hp=e1d46c6772bf88b0008351d1e0d6a573a13fb43c;hpb=9de4221e6eb08e4311cefce703486ff5bc56fabf;p=oota-llvm.git diff --git a/include/llvm/SymbolTableListTraits.h b/include/llvm/SymbolTableListTraits.h index e1d46c6772b..91a4eb99ff0 100644 --- a/include/llvm/SymbolTableListTraits.h +++ b/include/llvm/SymbolTableListTraits.h @@ -28,15 +28,14 @@ #include "llvm/ADT/ilist.h" namespace llvm { - +class ValueSymbolTable; + template class ilist_iterator; template class iplist; template struct ilist_traits; -// ValueSubClass - The type of objects that I hold, e.g. Instruction. -// ItemParentType - The type of object that owns the list, e.g. BasicBlock. -// TraitBaseClass - The class this trait should inherit from, it should -// inherit from ilist_traits +// ValueSubClass - The type of objects that I hold, e.g. Instruction. +// ItemParentClass - The type of object that owns the list, e.g. BasicBlock. // template class SymbolTableListTraits : public ilist_default_traits { @@ -47,8 +46,20 @@ public: /// getListOwner - Return the object that owns this list. If this is a list /// of instructions, it returns the BasicBlock that owns them. ItemParentClass *getListOwner() { - return reinterpret_cast(reinterpret_cast(this)- - TraitsClass::getListOffset()); + typedef iplist ItemParentClass::*Sublist; + size_t Offset(size_t(&((ItemParentClass*)0->*ItemParentClass:: + getSublistAccess(static_cast(0))))); + iplist* Anchor(static_cast*>(this)); + return reinterpret_cast(reinterpret_cast(Anchor)- + Offset); + } + + static iplist &getList(ItemParentClass *Par) { + return Par->*(Par->getSublistAccess((ValueSubClass*)0)); + } + + static ValueSymbolTable *getSymTab(ItemParentClass *Par) { + return Par ? toPtr(Par->getValueSymbolTable()) : 0; } void addNodeToList(ValueSubClass *V); @@ -59,6 +70,8 @@ public: //private: template void setSymTabObject(TPtr *, TPtr); + static ValueSymbolTable *toPtr(ValueSymbolTable *P) { return P; } + static ValueSymbolTable *toPtr(ValueSymbolTable &R) { return &R; } }; } // End llvm namespace