]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - opencl/llvm.git/commitdiff
Revert "Fix UBSan report in StringMap implementation."
authorAlexey Samsonov <vonosmas@gmail.com>
Thu, 4 Dec 2014 23:00:50 +0000 (23:00 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Thu, 4 Dec 2014 23:00:50 +0000 (23:00 +0000)
This reverts commit r223402. Some bots fail with -Winvalid-offsetof
warning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223407 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringMap.h

index 06afe8426919b823f341fe81a688f627438a7cf6..2feb2ab0074d406a04fbd1c8bc92edcf56674352 100644 (file)
@@ -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) {