<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">So we capture the format in a “const char *” and it is obviously not available for sanitizing by the time we use it to call snprintf.<div class=""><br class=""></div><div class="">Any other idea?</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 5, 2016, at 6:11 PM, Mehdi Amini via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">That’s a good idea, unfortunately: "error: format attribute requires variadic function”.<div class=""><br class=""></div><div class="">Also since we end up calling snprintf, I wonder why we don’t already catch these there, it is correctly decorated with the attribute on Darwin. Issue with variadic template (or template alone)? I should try a minimal test case.</div><div class=""><br class=""></div><div class=""> </div><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Oct 5, 2016, at 9:35 AM, Zachary Turner <<a href="mailto:zturner@google.com" class="">zturner@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Can't you add __attribute__((format(printf))); to the constructor?  That would catch these issues.</div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Oct 5, 2016 at 9:05 AM Mehdi AMINI via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">mehdi_amini added a comment.<br class="gmail_msg">
<br class="gmail_msg">
This is also catching existing latent bugs in the codebase:<br class="gmail_msg">
<br class="gmail_msg">
  In file included from /llvm-project/llvm/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp:55:<br class="gmail_msg">
  /llvm-project/llvm/include/llvm/Support/Format.h:82:3: error: static_assert failed "format can't be used with non fundamental / non pointer type"<br class="gmail_msg">
    static_assert(std::is_scalar<Arg>::value,<br class="gmail_msg">
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~<br class="gmail_msg">
  /llvm-project/llvm/include/llvm/Support/Format.h:105:5: note: in instantiation of template class 'llvm::validate_format_parameters<llvm::StringRef>' requested here<br class="gmail_msg">
      validate_format_parameters<Ts...>();<br class="gmail_msg">
      ^<br class="gmail_msg">
  /llvm-project/llvm/include/llvm/Support/Format.h:124:10: note: in instantiation of member function 'llvm::format_object<llvm::StringRef>::format_object' requested here<br class="gmail_msg">
    return format_object<Ts...>(Fmt, Vals...);<br class="gmail_msg">
           ^<br class="gmail_msg">
  /llvm-project/llvm/lib/Target/PowerPC/PPCVSXSwapRemoval.cpp:965:21: note: in instantiation of function template specialization 'llvm::format<llvm::StringRef>' requested here<br class="gmail_msg">
      DEBUG(dbgs() << format("  %14s  ", TII->getName(MI->getOpcode())));<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D25266" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D25266</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
llvm-commits mailing list<br class="gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="gmail_msg">
</blockquote></div>
</div></blockquote></div><br class=""></div></div></div>_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""></div></blockquote></div><br class=""></div></body></html>