[PATCH] Fix PR22047: ObjC: Method unavailability attribute doesn't work with overloaded methods

Jonathan Roelofs jonathan at codesourcery.com
Fri Apr 24 11:39:41 PDT 2015


+thakis

On 4/24/15 12:31 PM, Aaron Ballman wrote:
> On Fri, Apr 24, 2015 at 2:25 PM, Jonathan Roelofs
> <jonathan at codesourcery.com> wrote:
>> Hi aaron.ballman,
>>
>> http://reviews.llvm.org/D9261
>>
>> Files:
>>    lib/Sema/SemaDeclObjC.cpp
>>    test/SemaObjC/multiple-method-names.m
>>
>> Index: lib/Sema/SemaDeclObjC.cpp
>> ===================================================================
>> --- lib/Sema/SemaDeclObjC.cpp
>> +++ lib/Sema/SemaDeclObjC.cpp
>> @@ -2385,10 +2385,10 @@
>>     // Diagnose finding more than one method in global pool
>>     SmallVector<ObjCMethodDecl *, 4> Methods;
>>     Methods.push_back(BestMethod);
>> -  for (ObjCMethodList *M = &MethList; M; M = M->getNext())
>> -    if (M->getMethod() && !M->getMethod()->isHidden() &&
>> -        M->getMethod() != BestMethod)
>> -      Methods.push_back(M->getMethod());
>> +  for (ObjCMethodList *ML = &MethList; ML; ML = ML->getNext())
>
> Do we not have a range adapter for this? Weird.

I'm surprised there isn't even begin()/end() on it.

>
>> +    if (ObjCMethodDecl *M = ML->getMethod())
>> +      if (!M->isHidden() && M != BestMethod && !M->hasAttr<UnavailableAttr>())
>> +        Methods.push_back(M);
>>     if (Methods.size() > 1)
>>       DiagnoseMultipleMethodInGlobalPool(Methods, Sel, R, receiverIdOrClass);
>>
>> @@ -2420,7 +2420,7 @@
>>                                                 bool receiverIdOrClass) {
>>     // We found multiple methods, so we may have to complain.
>>     bool issueDiagnostic = false, issueError = false;
>> -
>> +
>
> This looks like a spurious change.
>
>>     // We support a warning which complains about *any* difference in
>>     // method signature.
>>     bool strictSelectorMatch =
>> @@ -2434,7 +2434,7 @@
>>         }
>>       }
>>     }
>> -
>> +
>
> Same here.

These two are drive-by whitespace fixes.

>
>>     // If we didn't see any strict differences, we won't see any loose
>>     // differences.  In ARC, however, we also need to check for loose
>>     // mismatches, because most of them are errors.
>> Index: test/SemaObjC/multiple-method-names.m
>> ===================================================================
>> --- test/SemaObjC/multiple-method-names.m
>> +++ test/SemaObjC/multiple-method-names.m
>> @@ -0,0 +1,19 @@
>> +// RUN: %clang_cc1 -Wobjc-multiple-method-names -x objective-c %s -verify
>> +// PR22047
>> +
>> + at interface Face0
>> +- (void)foo:(float)i; // expected-note {{using}}
>> + at end
>> +
>> + at interface Face1
>> +- (void)foo:(int)i __attribute__((unavailable));
>> + at end
>> +
>> + at interface Face2
>> +- (void)foo:(char)i; // expected-note {{also found}}
>> + at end
>> +
>> +void f(id i) {
>> +  [i foo:4.0f]; // expected-warning {{multiple methods named 'foo:' found}}
>> +}
>> +
>
> Aside from tiny nits, LGTM! You may want to wait for jahanian to chime
> in though, since my ObjC is rusty at best.

Sounds good, I'll wait.


Jon

>
> ~Aaron
>
>>
>> EMAIL PREFERENCES
>>    http://reviews.llvm.org/settings/panel/emailpreferences/

-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-commits mailing list