[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 7 13:22:07 PDT 2018


smeenai added a comment.

Note that the alignment matters in addition to the size.

The pattern I've seen internally is people using `%zd` for NSInteger and `%tu` for NSUInteger, since until clang 6 neither of those were format-checked at all.

I'd be fine with adding an option to relax the printf checking if the size and alignment of the specifier and the actual type match, even if the types themselves differ (`-Wformat-relaxed` or something similar), so that you'd still get warnings on cases where the specifier mismatch could cause runtime issues. I think that would be preferable to special-casing the Apple types.


Repository:
  rC Clang

https://reviews.llvm.org/D42933





More information about the cfe-commits mailing list