<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - Broken selector table when ObjectiveC is not the first module"
   href="http://llvm.org/bugs/show_bug.cgi?id=19135">19135</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Broken selector table when ObjectiveC is not the first module
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Modules
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jordan_rose@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12229" name="attach_12229" title="Test case.">attachment 12229</a> <a href="attachment.cgi?id=12229&action=edit" title="Test case.">[details]</a></span>
Test case.

If a module contains random Objective-C selectors (either in a method
declaration or in an @selector() expression), but does not import the
ObjectiveC module (containing the declaration of the NSObject protocol), then
the actual ObjectiveC module will use the wrong selectors for the methods on
the NSObject protocol. (See attached test case.)

% clang -fsyntax-only -fmodules -x objective-c -I FakeRoot FakeRoot/test.m
FakeRoot/test.m:5:11: warning: instance method '-isEqual:'
      not found (return type defaults to 'id') [-Wobjc-method-access]
  [object isEqual:object];
          ^~~~~~~

Here's what I get when I dump the NSObject protocol in the debugger. Notice
that the selectors don't match up with the parameters and return type of each
function.

(lldb) p this->LoadLexicalDeclsFromExternalStorage()
(lldb) p this->dump()
ObjCProtocolDecl 0x109092338 </usr/include/objc/NSObject.h:13:1, line:44:2> in
ObjectiveC.NSObject NSObject
|-ObjCMethodDecl 0x10909a658 <line:15:1, col:27> in ObjectiveC.NSObject - self
'BOOL':'signed char'
| `-ParmVarDecl 0x10909a778 <col:18, col:21> in ObjectiveC.NSObject object
'id':'id'
|-ObjCMethodDecl 0x10909a7f0 <line:16:1, col:19> in ObjectiveC.NSObject -
isProxy 'NSUInteger':'unsigned long'
|-ObjCMethodDecl 0x10909a918 <line:18:1, col:20> in ObjectiveC.NSObject -
release 'Class':'Class'
|-ObjCMethodDecl 0x10909a9d8 <line:19:1, col:15> in ObjectiveC.NSObject -
retainCount 'Class':'Class'
|-ObjCMethodDecl 0x10909aa78 <line:20:1, col:11> in ObjectiveC.NSObject -
superclass 'id':'id'
|-ObjCMethodDecl 0x10909ab18 <line:21:1, col:46> in ObjectiveC.NSObject - hash
'struct _NSZone *'
|-ObjCMethodDecl 0x10909ad00 <line:23:1, col:37> in ObjectiveC.NSObject -
autorelease 'id':'id'
| `-ParmVarDecl 0x10909ada0 <col:24, col:28> in ObjectiveC.NSObject aSelector
'SEL':'SEL *'
|-ObjCMethodDecl 0x10909ae40 <line:24:1, col:59> in ObjectiveC.NSObject -
debugDescription 'id':'id'
| |-ParmVarDecl 0x10909aee0 <col:24, col:28> in ObjectiveC.NSObject aSelector
'SEL':'SEL *'
| `-ParmVarDecl 0x10909af50 <col:50, col:53> in ObjectiveC.NSObject object
'id':'id'
|-ObjCMethodDecl 0x10909afd0 <line:25:1, col:83> in ObjectiveC.NSObject - class
'id':'id'
| |-ParmVarDecl 0x10909b070 <col:24, col:28> in ObjectiveC.NSObject aSelector
'SEL':'SEL *'
| |-ParmVarDecl 0x10909b0e0 <col:50, col:53> in ObjectiveC.NSObject object1
'id':'id'
| `-ParmVarDecl 0x10909b150 <col:73, col:76> in ObjectiveC.NSObject object2
'id':'id'
|-ObjCMethodDecl 0x10909b1d8 <line:27:1, col:16> in ObjectiveC.NSObject -
respondsToSelector: 'BOOL':'signed char'
|-ObjCMethodDecl 0x10909b278 <line:29:1, col:36> in ObjectiveC.NSObject -
performSelector:withObject:withObject: 'BOOL':'signed char'
| `-ParmVarDecl 0x10909b318 <col:24, col:30> in ObjectiveC.NSObject aClass
'Class':'Class'
|-ObjCMethodDecl 0x10909b390 <line:30:1, col:38> in ObjectiveC.NSObject -
foobarbaz 'BOOL':'signed char'
| `-ParmVarDecl 0x10909b430 <col:26, col:32> in ObjectiveC.NSObject aClass
'Class':'Class'
|-ObjCMethodDecl 0x10909b4a8 <line:31:1, col:49> in ObjectiveC.NSObject - zone
'BOOL':'signed char'
| `-ParmVarDecl 0x10909b548 <col:29, col:40> in ObjectiveC.NSObject aProtocol
'Protocol *'
|-ObjCMethodDecl 0x10909c418 <line:33:1, col:42> in ObjectiveC.NSObject -
description 'BOOL':'signed char'
| `-ParmVarDecl 0x10909c4b8 <col:29, col:33> in ObjectiveC.NSObject aSelector
'SEL':'SEL *'
|-ObjCMethodDecl 0x10909c530 <line:35:1, col:34> in ObjectiveC.NSObject -
isMemberOfClass: 'id':'id'
|-ObjCMethodDecl 0x10909c5d8 <line:36:1, col:44> in ObjectiveC.NSObject -
performSelector:withObject: 'void'
|-ObjCMethodDecl 0x10909c680 <line:37:1, col:39> in ObjectiveC.NSObject -
conformsToProtocol: 'id':'id'
|-ObjCMethodDecl 0x10909c728 <line:38:1, col:47> in ObjectiveC.NSObject -
retain 'NSUInteger':'unsigned long'
|-ObjCMethodDecl 0x10909c7d0 <line:40:1, col:26> in ObjectiveC.NSObject -
isKindOfClass: 'NSString *'
`-ObjCMethodDecl 0x10909c948 <line:42:1, col:31> in ObjectiveC.NSObject -
performSelector: 'NSString *'</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>