summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fb8dcb4)
raw | patch | inline | side by side (parent: fb8dcb4)
author | Alexey Samsonov <vonosmas@gmail.com> | |
Thu, 4 Dec 2014 22:45:31 +0000 (22:45 +0000) | ||
committer | Alexey Samsonov <vonosmas@gmail.com> | |
Thu, 4 Dec 2014 22:45:31 +0000 (22:45 +0000) |
Use offsetof() instead of a member access within null pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223402 91177308-0d34-0410-b5e6-96231b3b80d8
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223402 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/StringMap.h | patch | blob | history |
index 2feb2ab0074d406a04fbd1c8bc92edcf56674352..06afe8426919b823f341fe81a688f627438a7cf6 100644 (file)
/// GetStringMapEntryFromValue - Given a value that is known to be embedded
/// into a StringMapEntry, return the StringMapEntry itself.
static StringMapEntry &GetStringMapEntryFromValue(ValueTy &V) {
- StringMapEntry *EPtr = 0;
- char *Ptr = reinterpret_cast<char*>(&V) -
- (reinterpret_cast<char*>(&EPtr->second) -
- reinterpret_cast<char*>(EPtr));
+ char *Ptr = reinterpret_cast<char *>(&V) - offsetof(StringMapEntry, second);
return *reinterpret_cast<StringMapEntry*>(Ptr);
}
static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) {