<div dir="ltr">Thanks for taking care of this!</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 7, 2015 at 12:04 PM, Justin Bogner via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: bogner<br>
Date: Mon Dec  7 14:04:57 2015<br>
New Revision: 254935<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=254935&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=254935&view=rev</a><br>
Log:<br>
AST: defer to TypeLoc::copy in TypeLoc::initializeFullCopy<br>
<br>
If we're initializing a TypeLoc from one that's been allocated with<br>
different alignment, memcpy will get the padding wrong. The `copy`<br>
method already checks and handles this case, so we should just defer<br>
to it.<br>
<br>
This also drops the `const` off of the `initializeFullCopy`<br>
declarations, since it isn't even remotely true (and the compiler<br>
notices when we try to call copy() instead of tricking it with<br>
memcpy).<br>
<br>
Fixes <a href="http://llvm.org/pr23516" rel="noreferrer" target="_blank">llvm.org/pr23516</a>.<br>
<br>
Modified:<br>
    cfe/trunk/include/clang/AST/TypeLoc.h<br>
<br>
Modified: cfe/trunk/include/clang/AST/TypeLoc.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=254935&r1=254934&r2=254935&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TypeLoc.h?rev=254935&r1=254934&r2=254935&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/TypeLoc.h (original)<br>
+++ cfe/trunk/include/clang/AST/TypeLoc.h Mon Dec  7 14:04:57 2015<br>
@@ -170,19 +170,18 @@ public:<br>
<br>
   /// \brief Initializes this by copying its information from another<br>
   /// TypeLoc of the same type.<br>
-  void initializeFullCopy(TypeLoc Other) const {<br>
+  void initializeFullCopy(TypeLoc Other) {<br>
     assert(getType() == Other.getType());<br>
-    size_t Size = getFullDataSize();<br>
-    memcpy(getOpaqueData(), Other.getOpaqueData(), Size);<br>
+    copy(Other);<br>
   }<br>
<br>
   /// \brief Initializes this by copying its information from another<br>
   /// TypeLoc of the same type.  The given size must be the full data<br>
   /// size.<br>
-  void initializeFullCopy(TypeLoc Other, unsigned Size) const {<br>
+  void initializeFullCopy(TypeLoc Other, unsigned Size) {<br>
     assert(getType() == Other.getType());<br>
     assert(getFullDataSize() == Size);<br>
-    memcpy(getOpaqueData(), Other.getOpaqueData(), Size);<br>
+    copy(Other);<br>
   }<br>
<br>
   /// Copies the other type loc into this one.<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</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>