<div dir="ltr">Reverted, sorry about the noise.</div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 4, 2014 at 2:58 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Dec 4, 2014 at 2:45 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: samsonov<br>
Date: Thu Dec  4 16:45:31 2014<br>
New Revision: 223402<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223402&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223402&view=rev</a><br>
Log:<br>
Fix UBSan report in StringMap implementation.<br>
<br>
Use offsetof() instead of a member access within null pointer.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/ADT/StringMap.h<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/StringMap.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=223402&r1=223401&r2=223402&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringMap.h?rev=223402&r1=223401&r2=223402&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/StringMap.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/StringMap.h Thu Dec  4 16:45:31 2014<br>
@@ -182,10 +182,7 @@ public:<br>
   /// GetStringMapEntryFromValue - Given a value that is known to be embedded<br>
   /// into a StringMapEntry, return the StringMapEntry itself.<br>
   static StringMapEntry &GetStringMapEntryFromValue(ValueTy &V) {<br>
-    StringMapEntry *EPtr = 0;<br>
-    char *Ptr = reinterpret_cast<char*>(&V) -<br>
-                  (reinterpret_cast<char*>(&EPtr->second) -<br>
-                   reinterpret_cast<char*>(EPtr));<br>
+    char *Ptr = reinterpret_cast<char *>(&V) - offsetof(StringMapEntry, second);<br></blockquote></span><div><br><div>llvm/src/include/llvm/ADT/StringMap.h:185:48: error: offset of on non-standard-layout type 'llvm::StringMapEntry<llvm::MDString>' [-Werror,-Winvalid-offsetof]</div><span class=""><div>    char *Ptr = reinterpret_cast<char *>(&V) - offsetof(StringMapEntry, second);</div></span><div>                                               ^                        ~~~~~~</div> </div><span class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
     return *reinterpret_cast<StringMapEntry*>(Ptr);<br>
   }<br>
   static const StringMapEntry &GetStringMapEntryFromValue(const ValueTy &V) {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></span></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div>