[cfe-commits] Patch: PR9751: -Wformat warnings will point to the callsite and give a note if the format string is elsewhere.

Richard Trieu rtrieu at google.com
Thu Oct 13 14:38:57 PDT 2011


-Wformat warnings will point to the format string, but no message at the
call site.  This patch will move the warning to always point at the call
site.  If the format string is part of the function call, one warning will
show.  If the format string is defined elsewhere, a warning at the call site
plus a note where the format string is defined.

Also, if a note is present, the fix-it would be moved to the note so they
won't be applied with -fixit.  If the format string was used in multiple
places, fixits may cause problems in other places.

printf("%d %d", 1);

warning: more '%' conversions than data arguments [-Wformat]
printf("%d %d", 1);

const char kFormat[] = "%d %d";
printf(kFormat, 1);

test2.c:8:8: warning: more '%' conversions than data arguments [-Wformat]
printf(kFormat, 1);
test2.c:7:29: note: format string is defined here
const char kFormat[] = "%d %d";

Patch attached an available at http://codereview.appspot.com/5277043/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111013/270f8b16/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: format-warnings.patch
Type: text/x-patch
Size: 29802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20111013/270f8b16/attachment.bin>

More information about the cfe-commits mailing list