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

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 15:00:25 PST 2018


arphaman created this revision.
arphaman added reviewers: ahatanak, vsapsai.
Herald added subscribers: jkorous-apple, kristof.beyls, aemerson.

The -Wformat recently started warning for the following code because of the added support for analysis for the '%zi' specifier.

  NSInteger i = NSIntegerMax;
  NSLog(@"max NSInteger = %zi", i);

The problem is that on armv7 %zi is 'long', and NSInteger is typedefed to 'int' in Foundation. We should avoid this warning as it's inconvenient to our users: it's target specific (happens only on armv7 and not arm64), and breaks their existing code. We should also silence the warning for the '%zu' specifier to ensure consistency.

rdar://36874921


Repository:
  rC Clang

https://reviews.llvm.org/D42933

Files:
  include/clang/Analysis/Analyses/FormatString.h
  lib/Analysis/PrintfFormatString.cpp
  lib/Sema/SemaChecking.cpp
  test/SemaObjC/format-size-spec-nsinteger.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42933.132892.patch
Type: text/x-patch
Size: 4132 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180205/08a6b186/attachment.bin>


More information about the cfe-commits mailing list