[llvm-commits] [llvm] r42918 - /llvm/trunk/include/llvm/ADT/StringMap.h
Chris Lattner
sabre at nondot.org
Fri Oct 12 10:49:52 PDT 2007
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));
More information about the llvm-commits
mailing list