summaryrefslogtreecommitdiffstats
path: root/include/llvm/SymbolTableListTraits.h
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2009-03-07 10:00:35 +0000
committerGabor Greif <ggreif@gmail.com>2009-03-07 10:00:35 +0000
commitb547a181005cc255fa57c61c1c0dbafca5375fb4 (patch)
treeb410d6b76be08d5820401da6eb8f015fdd7d68fc /include/llvm/SymbolTableListTraits.h
parent922a881f32df95170cb2c28e1a5ee0053d6f0f90 (diff)
downloadexternal_llvm-b547a181005cc255fa57c61c1c0dbafca5375fb4.zip
external_llvm-b547a181005cc255fa57c61c1c0dbafca5375fb4.tar.gz
external_llvm-b547a181005cc255fa57c61c1c0dbafca5375fb4.tar.bz2
Remove the burden of dealing with list offsets
from SymbolTableListTraits' clients, and intead request a nice declarative interface. Cleans up an IMHO ugly wart. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66331 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/SymbolTableListTraits.h')
-rw-r--r--include/llvm/SymbolTableListTraits.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/llvm/SymbolTableListTraits.h b/include/llvm/SymbolTableListTraits.h
index a6d3e68..b5ec20d 100644
--- a/include/llvm/SymbolTableListTraits.h
+++ b/include/llvm/SymbolTableListTraits.h
@@ -45,8 +45,13 @@ 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<ItemParentClass*>(reinterpret_cast<char*>(this)-
- TraitsClass::getListOffset());
+ typedef iplist<ValueSubClass> ItemParentClass::*Sublist;
+ Sublist Sub(ItemParentClass::
+ getSublistAccess(static_cast<ValueSubClass*>(0)));
+ size_t Offset(size_t(&((ItemParentClass*)0->*Sub)));
+ iplist<ValueSubClass>* Anchor(static_cast<iplist<ValueSubClass>*>(this));
+ return reinterpret_cast<ItemParentClass*>(reinterpret_cast<char*>(Anchor)-
+ Offset);
}
void addNodeToList(ValueSubClass *V);