[PATCH] D25820: [Sema][Objective-C] Formatting warnings should see through Objective-C message sends

Ben Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 5 10:08:06 PST 2018

benhamilton added a comment.

I filed rdar://38143508 to track this.

The fix won't be easy; I think `__attribute__((format_arg(X)))` isn't enough to capture how `-[NSBundle localizedStringForKey:value:table:]` works:

1. `__attribute__((format_arg(X)))` doesn't support multiple format arguments, and it appears to ignore everything but the last such declaration:


2. `NSLocalizedString()` and friends pass `@""` as the value argument, which raises `-Wformat-zero-length` if we tag it as a format argument:

  test.m:21:12: error: format string is empty [-Werror,-Wformat-zero-length]
  test.m:14:46: note: expanded from macro 'NSLocalizedStringWithDefaultValue'
    [bundle localizedStringForKey:(key) value:(val) table:(tbl)]
  1 error generated.

This means we'll either need a new attribute which allows a zero-length format string, or a way to change format_arg to understand this "argument with default value" semantic.



More information about the cfe-commits mailing list