[cfe-dev] Relaxing format specifier checks

Shoaib Meenai via cfe-dev cfe-dev at lists.llvm.org
Tue May 15 13:29:23 PDT 2018


I was planning on waiting a few more days to give more people a chance to chime in. Let's wait till the end of the week?

From: <jfbastien at apple.com> on behalf of JF Bastien <jfbastien at apple.com>
Date: Tuesday, May 15, 2018 at 1:21 PM
To: James Y Knight <jyknight at google.com>
Cc: Shoaib Meenai <smeenai at fb.com>, cfe-dev <cfe-dev at lists.llvm.org>
Subject: Re: [cfe-dev] Relaxing format specifier checks




On May 13, 2018, at 8:18 PM, James Y Knight via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:


On Fri, May 11, 2018, 7:26 PM Shoaib Meenai via cfe-dev <cfe-dev at lists.llvm.org<mailto: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.


Sounds like there’s support for doing this.

Shoaib, how would you rather proceed?



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.

_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180515/0d955705/attachment.html>


More information about the cfe-dev mailing list