<br><br><div class="gmail_quote">On Thu, Oct 13, 2011 at 5:18 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com">rtrieu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="gmail_quote"><div><div class="h5">On Thu, Oct 13, 2011 at 3:25 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div><div>On Thu, Oct 13, 2011 at 2:53 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@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><div>On Thu, Oct 13, 2011 at 2:38 PM, Richard Trieu <<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>> wrote:<br>
> <a href="http://llvm.org/bugs/show_bug.cgi?id=9751" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=9751</a><br>
> -Wformat warnings will point to the format string, but no message at the<br>
> call site. This patch will move the warning to always point at the call<br>
> site. If the format string is part of the function call, one warning will<br>
> show. If the format string is defined elsewhere, a warning at the call site<br>
> plus a note where the format string is defined.<br>
> Also, if a note is present, the fix-it would be moved to the note so they<br>
> won't be applied with -fixit. If the format string was used in multiple<br>
> places, fixits may cause problems in other places.<br>
> printf("%d %d", 1);<br>
> warning: more '%' conversions than data arguments [-Wformat]<br>
> printf("%d %d", 1);<br>
> ~^<br>
> const char kFormat[] = "%d %d";<br>
> printf(kFormat, 1);<br>
> test2.c:8:8: warning: more '%' conversions than data arguments [-Wformat]<br>
> printf(kFormat, 1);<br>
> ^~~~~~~<br>
> test2.c:7:29: note: format string is defined here<br>
> const char kFormat[] = "%d %d";<br>
> ~^<br>
> Patch attached an available at <a href="http://codereview.appspot.com/5277043/" target="_blank">http://codereview.appspot.com/5277043/</a><br>
<br>
</div></div>+namespace {<br>
+ class StringLiteralFinder<br>
+ : public ConstStmtVisitor<StringLiteralFinder> {<br>
+ Sema& S;<br>
+ const StringLiteral *StringExpr;<br>
+ bool StringFound;<br>
+ public:<br>
[...]<br>
<br>
Why is StringLiteralFinder necessary? The caller should know how it<br>
found the string literal...<br>
<br></blockquote></div></div><div>That information isn't currently preserved through the diagnostics. The StringLiteralFinder is necessary to determine this after the fact. I can go look again and see if I can propagate that bit of info through the code.</div>
<div>
<div> </div></div></div></blockquote></div></div><div>Turns out, it was easier to to pass around a bool with this info than I originally thought. New patch attached.</div></div>
</blockquote></div><br><div>Ping.</div>