[llvm] r223407 - Revert "Fix UBSan report in StringMap implementation."

Alexey Samsonov vonosmas at gmail.com
Thu Dec 4 15:00:50 PST 2014


Author: samsonov
Date: Thu Dec  4 17:00:50 2014
New Revision: 223407

URL: http://llvm.org/viewvc/llvm-project?rev=223407&view=rev
Log:
Revert "Fix UBSan report in StringMap implementation."

This reverts commit r223402. Some bots fail with -Winvalid-offsetof
warning.

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=223407&r1=223406&r2=223407&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)
+++ llvm/trunk/include/llvm/ADT/StringMap.h Thu Dec  4 17:00:50 2014
@@ -182,7 +182,10 @@ public:
   /// GetStringMapEntryFromValue - Given a value that is known to be embedded
   /// into a StringMapEntry, return the StringMapEntry itself.
   static StringMapEntry &GetStringMapEntryFromValue(ValueTy &V) {
-    char *Ptr = reinterpret_cast<char *>(&V) - offsetof(StringMapEntry, second);
+    StringMapEntry *EPtr = 0;
+    char *Ptr = reinterpret_cast<char*>(&V) -
+                  (reinterpret_cast<char*>(&EPtr->second) -
+                   reinterpret_cast<char*>(EPtr));
     return *reinterpret_cast<StringMapEntry*>(Ptr);
   }
   static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) {





More information about the llvm-commits mailing list