From: Chris Lattner Date: Fri, 12 Oct 2007 17:49:52 +0000 (+0000) Subject: Make this compute the correct offset, handling alignment of the element X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=b89f67e3e659da1f11c01f2aac1be3463dc60f07;p=oota-llvm.git Make this compute the correct offset, handling alignment of the element pointer correctly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42918 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index fecd61ead1b..7f8657e5609 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -171,8 +171,9 @@ public: /// 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)); + StringMapEntry *EPtr = 0; + char *Ptr = reinterpret_cast(&V) - (intptr_t)&EPtr->Val; + return *reinterpret_cast(Ptr); } static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) { return GetStringMapEntryFromValue(const_cast(V));