aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-12 17:49:52 +0000
committerChris Lattner <sabre@nondot.org>2007-10-12 17:49:52 +0000
commitb89f67e3e659da1f11c01f2aac1be3463dc60f07 (patch)
treedd4779cee536af49ed0a947f069f42d761c9bb99 /include/llvm/ADT
parent48ff282dd49197d2b42285b769126ba7991aa93a (diff)
downloadexternal_llvm-b89f67e3e659da1f11c01f2aac1be3463dc60f07.zip
external_llvm-b89f67e3e659da1f11c01f2aac1be3463dc60f07.tar.gz
external_llvm-b89f67e3e659da1f11c01f2aac1be3463dc60f07.tar.bz2
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
Diffstat (limited to 'include/llvm/ADT')
-rw-r--r--include/llvm/ADT/StringMap.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index fecd61e..7f8657e 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<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));