Page MenuHomePhabricator

[analyzer] Add annotation for functions taking user-facing strings
ClosedPublic

Authored by erikjv on Jul 9 2017, 12:47 PM.

Details

Summary

There was already a returns_localized_nsstring annotation to indicate
that the return value could be passed to UIKit methods that would
display them. However, those UIKit methods were hard-coded, and it was
not possible to indicate that other classes/methods in a code-base would
do the same.

The takes_localized_nsstring annotation can be put on function
parameters and selector parameters to indicate that those will also show
the string to the user.

Diff Detail

Repository
rL LLVM

Event Timeline

erikjv created this revision.Jul 9 2017, 12:47 PM
erikjv updated this revision to Diff 105792.Jul 9 2017, 12:53 PM

Sorry, now with more context in the diff.

jordan_rose edited reviewers, added: dcoughlin; removed: jordan_rose.Jul 10 2017, 10:15 AM
dcoughlin accepted this revision.Jul 10 2017, 6:24 PM

Thanks for the patch! This looks very good to me.

The one thing I would suggest is renaming 'isAnnotatedAsLocalized()' and 'isAnnotatedTakingLocalized()' to make it more clear what each does, now that there are two of them. How about: 'isAnnotatedAsReturningLocalized()' and 'isAnnotatedAsTakingLocalized()'?

This revision is now accepted and ready to land.Jul 10 2017, 6:24 PM
This revision was automatically updated to reflect the committed changes.