[PATCH] D48852: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %tu/%td on Darwin

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 2 14:41:55 PDT 2018


arphaman created this revision.
arphaman added a reviewer: jfb.
Herald added a subscriber: dexonsmith.

The '%tu'/'%td' as formatting specifiers have been used to print out the NSInteger/NSUInteger values for a long time. Typically their ABI matches (i.e. ptrdiff_t = NSInteger), but that's not the case on watchOS (ptrdiff_t = long, NSInteger = int). These specifiers trigger -Wformat warnings only for watchOS builds, which is really inconvenient for cross-platform code.

This patch avoids this `-Wformat` warning for '%tu'/'%td' and NS[U]Integer only, and instead uses the new `-Wformat-pedantic` warning that JF introduced in https://reviews.llvm.org/D47290. This is acceptable because Darwin guarantees that, despite the watchOS ABI differences, sizeof(ptrdiff_t) == sizeof(NS[U]Integer), so the warning is therefore noisy for pedantic reasons. Once this is in I'll update public documentation.

rdar://41739204


Repository:
  rC Clang

https://reviews.llvm.org/D48852

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: D48852.153799.patch
Type: text/x-patch
Size: 5318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180702/7f21b172/attachment-0001.bin>


More information about the cfe-commits mailing list