This is an archive of the discontinued LLVM Phabricator instance.

[clang] Fix printf fixit for objc specific types
ClosedPublic

Authored by alexander-shaposhnikov on Sep 21 2017, 4:44 PM.

Details

Summary

Let's take a look at the following example:
for the triple thumbv7-apple-ios8.0.0 ssize_t is long and size_t is unsigned long,
while NSInteger is int and NSUinteger is unsigned int.
Following https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
Clang will catch it and insert a cast to long, for example
printf("%zd", getNSInteger())
will be replaced with
printf("%zd", (long)getNSInteger())
but since the underlying type of ssize_t is long the specifier "%zd" is not getting replaced.
This diff changes this behavior to enable replacing the specifier "%zd" with the correct one.

Test plan: make check-all

Diff Detail

Repository
rL LLVM

Event Timeline

aaron.ballman accepted this revision.Sep 22 2017, 6:07 AM

Aside from a few minor nits, LGTM!

test/FixIt/fixit-format-ios.m
2 ↗(On Diff #116288)

I don't think you need to enable -fblocks for this test.

12–14 ↗(On Diff #116288)

Reflow these comments.

This revision is now accepted and ready to land.Sep 22 2017, 6:07 AM
alexander-shaposhnikov edited the summary of this revision. (Show Details)Sep 22 2017, 11:23 AM
This revision was automatically updated to reflect the committed changes.