[cfe-dev] Relaxing format specifier checks

James Y Knight via cfe-dev cfe-dev at lists.llvm.org
Sun May 13 20:18:39 PDT 2018


On Fri, May 11, 2018, 7:26 PM Shoaib Meenai via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> What are people's thoughts here? Are there preferences for relaxing
> -Wformat and adding a new option for strict format warnings vs. keeping
> -Wformat as-is and adding a new option for relaxed format warnings?
>

+1 to change the default behavior and put the stricter checks in another
flag, for all the reasons discussed already.

Of course, we should also ensure that the optimizer doesn't do anything
> surprising when there's a type mismatch between the specifier and the
> argument but both types have the same size and alignment (i.e., the case
> where the relaxed format warning won't fire), both now and in the future.
>

I think the concern here would be if clang did calling convention lowering
by generating a store of the outgoing argument with tbaa attached, and then
also generated a (potentially mismatched) tbaa-annotated load for the call
to va_arg inside the printf function. And then optimized the two functions
together.

I don't believe that can happen, both because the call arguments are not
lowered to memory stores (if needed) by clang, but rather by llvm (there's
no real possibility to attach TBAA at that point, even if we wanted to),
and also because clang doesn't attach tbaa to the loads generated by va_arg.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180513/04463ac7/attachment.html>


More information about the cfe-dev mailing list