forked from OSchip/llvm-project
Make this compute the correct offset, handling alignment of the element
pointer correctly. llvm-svn: 42918
This commit is contained in:
parent
431ef632cb
commit
4c461477bd
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue