Author: lattner Date: Fri Oct 12 12:49:52 2007 New Revision: 42918 URL: http://llvm.org/viewvc/llvm-project?rev=42918&view=rev Log: Make this compute the correct offset, handling alignment of the element pointer correctly.
Modified: llvm/trunk/include/llvm/ADT/StringMap.h Modified: llvm/trunk/include/llvm/ADT/StringMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=42918&r1=42917&r2=42918&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringMap.h (original) +++ llvm/trunk/include/llvm/ADT/StringMap.h Fri Oct 12 12:49:52 2007 @@ -171,8 +171,9 @@ /// 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<StringMapEntry*>(reinterpret_cast<char*>(&V) - - sizeof(StringMapEntryBase)); + StringMapEntry *EPtr = 0; + char *Ptr = reinterpret_cast<char*>(&V) - (intptr_t)&EPtr->Val; + return *reinterpret_cast<StringMapEntry*>(Ptr); } static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) { return GetStringMapEntryFromValue(const_cast<ValueTy&>(V)); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits