[LLVMbugs] [Bug 19135] New: Broken selector table when ObjectiveC is not the first module

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 13 15:33:54 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19135

            Bug ID: 19135
           Summary: Broken selector table when ObjectiveC is not the first
                    module
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Modules
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jordan_rose at apple.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 12229
  --> http://llvm.org/bugs/attachment.cgi?id=12229&action=edit
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 *'

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140313/fc800276/attachment.html>


More information about the llvm-bugs mailing list