]> granicus.if.org Git - clang/commit
[Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin
authorJF Bastien <jfbastien@apple.com>
Fri, 22 Jun 2018 21:54:40 +0000 (21:54 +0000)
committerJF Bastien <jfbastien@apple.com>
Fri, 22 Jun 2018 21:54:40 +0000 (21:54 +0000)
commitd71d946f368aa68e10672d5712e936a3b83b9975
tree8e0e43d2b53a65d34110c71a13d3802104f225bf
parent8246e4314763066223547505fe18a288f639a475
[Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

Summary:
Pick D42933 back up, and make NSInteger/NSUInteger with %zu/%zi specifiers on Darwin warn only in pedantic mode. The default -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. This is acceptable because Darwin guarantees that, despite the unfortunate choice of typedef, sizeof(size_t) == sizeof(NS[U]Integer), the warning is therefore noisy for pedantic reasons. Once this is in I'll update public documentation.

Related discussion on cfe-dev:
http://lists.llvm.org/pipermail/cfe-dev/2018-May/058050.html

<rdar://36874921&40501559>

Reviewers: ahatanak, vsapsai, alexshap, aaron.ballman, javed.absar, jfb, rjmccall

Subscribers: kristof.beyls, aheejin, cfe-commits

Differential Revision: https://reviews.llvm.org/D47290

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335393 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Analysis/Analyses/FormatString.h
include/clang/Basic/DiagnosticSemaKinds.td
lib/Analysis/PrintfFormatString.cpp
lib/Sema/SemaChecking.cpp
test/FixIt/fixit-format-ios-nopedantic.m [new file with mode: 0644]
test/FixIt/fixit-format-ios.m
test/SemaObjC/format-size-spec-nsinteger.m [new file with mode: 0644]