<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 30, 2012, at 4:26 PM, David Blaikie wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Wed, May 30, 2012 at 1:14 PM, Anna Zaks <span dir="ltr"><<a href="mailto:ganna@apple.com" target="_blank">ganna@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><br><div><div class="im"><div>On May 29, 2012, at 6:10 PM, Richard Smith wrote:</div><br><blockquote type="cite">Hi,<div><br></div><div><div class="gmail_quote">On Tue, May 29, 2012 at 5:34 PM, Anna Zaks <span dir="ltr"><<a href="mailto:ganna@apple.com" target="_blank">ganna@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: zaks<br>
Date: Tue May 29 19:34:21 2012<br>
New Revision: 157659<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=157659&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=157659&view=rev</a><br>
Log:<br>
Add fixits for memory access warnings.<br></blockquote><div><br></div><div>We have a rule that fix-its on warnings aren't supposed to change the code's semantics (-Werror -fixit shouldn't change the semantics of a valid program). Consequently, fix-its such as this are usually placed on an accompanying note.</div>

<div> </div></div></div></blockquote><br></div>We discussed this fixit internally, and reached a consensus that we should not issue a fixit in this case.</div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>The warning only warns on the following code, where the user most likely forgot to both dereference AND multiply by the number of elements. </div></div></blockquote><div><br></div><div>
It's likely they forgot the number of elements just because memcpy is usually used to copy several elements </div></div></blockquote><div><br></div><div>This is it.</div><br><blockquote type="cite"><div class="gmail_quote"><div>- or is there some other reason to believe the suggested fixit isn't really adequate?<br><br>I'm curious why we would suggest what amounts to a fixit in the diagnostic, but not as an actual fixit in a note (indeed the sentence fragment in the diagnostic could be pulled out into the text of the note).<br></div></div></blockquote><div><br></div><div>The proposal below is to extend the text proposal with the "(and multiply it by the number of elements)". It would be hard to issue a fixit in case they forgot to include the number of elements.</div><div><br></div><blockquote type="cite"><div class="gmail_quote"><div>
<br></div><div>- David</div><div> </div><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; "><div style="word-wrap:break-word"><div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 11px/normal Monaco">
 memcpy(to, from, <span style="color:#921e67">sizeof</span>(to));</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 11px/normal Monaco"><br></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 11px/normal Monaco">
<div style="font-family:Helvetica;font-size:medium">Note, we currently do not (but should) warn on the following, where the fixit would be more appropriate.</div><div style="font-family:Helvetica;font-size:medium"><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 11px/normal Monaco">
 memcpy(to, from, <span style="color:rgb(146,30,103)">sizeof</span>(to)*N);</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 11px/normal Monaco"></div></div></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 11px/normal Monaco"><br></div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font:normal normal normal 11px/normal Monaco">
<div style="font-family:Helvetica;font-size:medium">I plan to make the warning message more user-friendly:</div><div style="font-family:Helvetica;font-size:medium">-  warning: argument to 'sizeof' in 'memcpy' call is the same expression as the destination; did you mean to dereference it?</div>
<div class="im"><div style="font-family:Helvetica;font-size:medium"><div style="font-family:Helvetica;font-size:medium">-  memcpy(to, from, sizeof(to))</div><div><div style="font-family:Helvetica;font-size:medium">-                   ~~                      ~~</div>
</div><div><br></div></div></div><div style="font-family:Helvetica;font-size:medium">+  warning: 'memcpy' call operates on objects of type 'Blah' while the size is based on a different type 'Blah*'. </div>
<div style="font-family:Helvetica;font-size:medium">+  memcpy(to, from, sizeof(to))</div><div style="font-family:Helvetica;font-size:medium">+                   ~~                      ~~</div><div style="font-family:Helvetica;font-size:medium">
+  note: did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?</div><span class="HOEnZb"><font color="#888888"><div style="font-family:Helvetica;font-size:medium"><br></div>
<div style="font-family:Helvetica;font-size:medium">Anna.</div></font></span></div><div><div class="h5"><blockquote type="cite"><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Also, do not display the builtin name and macro expansion when the<br></blockquote></div></div></blockquote></div></div></div></div></blockquote></div><br>
</blockquote></div><br></body></html>