objc method lookup in super class implementation

Hello,

When clang lookup a method, it searches in the class implementation if it is in scope, but it does not try to search in super class implementation that may be in the scope too.

The result is that it emits "may not responds to selector" warning where it is obvious that the object will, as its superclass implement it.

Here is a patch to lookup in superclasses implementations (if in scope), and a test case.

lookup-superimpl.patch (1.92 KB)

Hi Jean-Daniel,

This patch looks good, however it doesn't handle 'super'.

snaroff% ../../../../Debug/bin/clang method-lookup-4.m
method-lookup-4.m:30:3: warning: method '-myMethod' not found (return type defaults to 'id')
   [super myMethod];
   ^~~~~~~~~~~~~~~~
1 diagnostic generated.

Since the patch relates to looking in super classes, it would be nice if it handled messages to 'super' as well.

Thanks,

snaroff

OK,

I will have a look at this, and I will also handle the class method case.

This patch is good and matches gcc's behavior (Steve's comment withstanding).
But a future strategy would be to do this checking as a final pass over all implementations,
to avoid warning being dependent on order of @implementation declarations.
Compile time would be a concern in that case, but multiple implementations in
one TU is generally not that common.

- Fariborz

A second version.

The "Lookup Private Instance Method" code is factored in a Sema method that is used in default method lookup,
super method lookup and also to find instance method of the root class in class method lookup.

lookup-private.patch (7.27 KB)