[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
Thu Jul 5 12:52:45 PDT 2018


arphaman marked an inline comment as done.
arphaman added a comment.

In https://reviews.llvm.org/D48852#1153415, @aaron.ballman wrote:

> > This is acceptable because Darwin guarantees that, despite the watchOS ABI differences, sizeof(ptrdiff_t) == sizeof(NS[U]Integer)
>
> Can you describe these ABI differences please? Also, does Darwin guarantee that alignof(ptrdiff_t) == alignof(NS[U]Integer)?


The ABI difference boils down to the following:

Regular 32-bit Darwin targets (like armv7) use 'ptrdiff_t' of type 'int', which matches 'NSInteger'.
WatchOS arm iOS target (armv7k) uses 'ptrdiff_t' of type 'long', which doesn't match 'NSInteger' of type 'int'.

> Also, does Darwin guarantee that alignof(ptrdiff_t) == alignof(NS[U]Integer)?

Yes.



================
Comment at: include/clang/Analysis/Analyses/FormatString.h:265
+  enum class TypeKind { Unspecified, SizeT, PtrdiffT };
+  TypeKind TK = TypeKind::Unspecified;
 
----------------
jfb wrote:
> "unspecified" seems odd because it *is* specified, we just don't care. How about something like "NothingSpecial" or "DontCare"?
Thanks. Changed to "DontCare".


================
Comment at: test/SemaObjC/format-size-spec-nsinteger.m:4
+// RUN: %clang_cc1 -triple thumbv7k-apple-watchos2.0.0 -fsyntax-only -fblocks -verify %s
+// RUN: %clang_cc1 -triple thumbv7k-apple-watchos2.0.0 -fsyntax-only -fblocks -verify -Wformat-pedantic -DPEDANTIC %s
 
----------------
jfb wrote:
> We use a bunch of different triples to test WatchOS:
> 
>    5 thumbv7k-apple-watchos2.0
>    3 i386-apple-watchos4
>    2 x86_64-apple-watchos
>    2 thumbv7k-apple-watchos
>    2 armv7k-apple-watchos3.0.0
>    2 armv7k-apple-watchos2.0
>    2 armv7k-apple-watchos
>    1 x86_64-apple-watchos-simulator
>    1 thumbv7k-apple-watchos1.0
>    1 i686-apple-watchos
>    1 i386-apple-watchos3.0-simulator
>    1 i386-apple-watchos3
>    1 i386-apple-watchos2.1
>    1 i386-apple-watchos2.0-simulator
>    1 i386-apple-watchos2.0
>    1 i386-apple-watchos-simulator
>    1 i386-apple-watchos
>    1 armv7k-apple-watchos2.1
>    1 armv7-apple-watchos
>    1 arm64-apple-watchos
>    1 aarch64-apple-watchos
> 
> Do we care about v7k only for this test?
Yes.
armv7k is used to generate thumbv7k .
i386 is used by simulator, and doesn't have this ABI issue.
We don't support other arches for watches.


Repository:
  rC Clang

https://reviews.llvm.org/D48852





More information about the cfe-commits mailing list