From: Chris Lattner Date: Sun, 30 Sep 2007 08:31:46 +0000 (+0000) Subject: Add a helper useful when mapping from a map element to its hash node. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1bcc79666dcdcc948b7b998f7f661c77c268a893;p=oota-llvm.git Add a helper useful when mapping from a map element to its hash node. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42480 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 72108e97e4f..fecd61ead1b 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -166,7 +166,18 @@ public: MallocAllocator A; return Create(KeyStart, KeyEnd, A); } - + + + /// GetStringMapEntryFromValue - Given a value that is known to be embedded + /// into a StringMapEntry, return the StringMapEntry itself. + static StringMapEntry &GetStringMapEntryFromValue(ValueTy &V) { + return *reinterpret_cast(reinterpret_cast(&V) - + sizeof(StringMapEntryBase)); + } + static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) { + return GetStringMapEntryFromValue(const_cast(V)); + } + /// Destroy - Destroy this StringMapEntry, releasing memory back to the /// specified allocator. template