<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - __attribute__((format_arg(X)) is broken with ObjC message sends"
   href="https://bugs.llvm.org/show_bug.cgi?id=36599">36599</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>__attribute__((format_arg(X)) is broken with ObjC message sends
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>bhamiltoncx@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I bisected this to <a href="https://reviews.llvm.org/D25820">https://reviews.llvm.org/D25820</a> / r284961 .

__attribute__((format_arg(X))) is supposed to mark a format argument as a
pass-through, but it no longer works with ObjC message sends.

Repro:

== apple clang-900.0.39.2: ok ==

% cat test.m
typedef unsigned int NSUInteger;

#define nil ((id)0)

@interface NSString
+ (id)stringWithFormat:(NSString *)fmt, ... __attribute__((format(__NSString__,
1, 2)));
@end

@interface NSBundle
- (NSString *)localizedStringForKey:(NSString *)key value:(nullable NSString
*)value table:(nullable NSString *)tableName __attribute__((format_arg(1)));
@end

#define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) \
  [bundle localizedStringForKey:(key) value:(val) table:(tbl)]

NSString *ShouldNotRaiseDataArgumentNotUsedByFormatString(NSUInteger count) {
  return [NSString stringWithFormat:NSLocalizedStringWithDefaultValue(
          @"foo",
          @"",
          nil,
          @"%d",
          @""),
          count];
}

% clang --version
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

% clang -fsyntax-only -Werror test.m && echo OK || echo NOT OK
OK

== r317698: bad ==

% clang --version
clang version 6.0.0 (trunk 317696) (llvm/trunk 317698)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /src/install/bin

% cat test.m
typedef unsigned int NSUInteger;

#define nil ((id)0)

@interface NSString
+ (id)stringWithFormat:(NSString *)fmt, ... __attribute__((format(__NSString__,
1, 2)));
@end

@interface NSBundle
- (NSString *)localizedStringForKey:(NSString *)key value:(nullable NSString
*)value table:(nullable NSString *)tableName __attribute__((format_arg(1)));
@end

#define NSLocalizedStringWithDefaultValue(key, tbl, bundle, val, comment) \
  [bundle localizedStringForKey:(key) value:(val) table:(tbl)]

NSString *ShouldNotRaiseDataArgumentNotUsedByFormatString(NSUInteger count) {
  return [NSString stringWithFormat:NSLocalizedStringWithDefaultValue(
          @"foo",
          @"",
          nil,
          @"%d",
          @""),
          count];
}

% clang -fsyntax-only -Werror test.m && echo OK || echo NOT OK
test.m:23:11: error: data argument not used by format string
[-Werror,-Wformat-extra-args]
          count];
          ^
1 error generated.
NOT OK</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>