r221562 - [Objective-C Sema]. Issue availability/deprecated warning when

Nico Weber thakis at chromium.org
Fri Dec 12 15:34:42 PST 2014


Ah, I think I found it. You indented it like this:

      if (Method) {
        if (ObjCMethodDecl *BestMethod =
              SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
          Method = BestMethod;
          SmallVector<ObjCMethodDecl*, 4> Methods;
          if (!CollectMultipleMethodsInGlobalPool(Sel, Methods,
Method->isInstanceMethod()))
            DiagnoseUseOfDecl(Method, SelLoc);
      }
    }

but clang-format tells you that it should be indented like so:

      if (Method) {
        if (ObjCMethodDecl *BestMethod =
                SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
          Method = BestMethod;
        SmallVector<ObjCMethodDecl *, 4> Methods;
        if (!CollectMultipleMethodsInGlobalPool(Sel, Methods,
                                                Method->isInstanceMethod()))
          DiagnoseUseOfDecl(Method, SelLoc);
      }
    }

That is, you added the {} to the outer if, but your indentation looks like
you mentioned to add them to the inner if. (I should dust off and check in
my -Windent warning.)

I'll try to come up with a test case, move the braces, and land that.
Please let me know if this looks like the wrong fix to you.



On Fri, Dec 12, 2014 at 1:54 PM, Nico Weber <thakis at chromium.org> wrote:

> This is causing http://llvm.org/bugs/show_bug.cgi?id=21587
>
> Looks like Sema::CollectMultipleMethodsInGlobalPool() should probably also
> look at stuff from an external sema source?
>
> On Fri, Nov 7, 2014 at 3:51 PM, Fariborz Jahanian <fjahanian at apple.com>
> wrote:
>
>> Author: fjahanian
>> Date: Fri Nov  7 17:51:15 2014
>> New Revision: 221562
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=221562&view=rev
>> Log:
>> [Objective-C Sema]. Issue availability/deprecated warning when
>> there is a uinque method found when message is sent to receiver
>> of 'id' type. // rdar://18848183
>>
>> Modified:
>>     cfe/trunk/lib/Sema/SemaExprObjC.cpp
>>     cfe/trunk/test/ARCMT/checking.m
>>     cfe/trunk/test/SemaObjC/attr-deprecated.m
>>
>> Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=221562&r1=221561&r2=221562&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Nov  7 17:51:15 2014
>> @@ -2448,10 +2448,14 @@ ExprResult Sema::BuildInstanceMessage(Ex
>>          Method = LookupFactoryMethodInGlobalPool(Sel,
>>
>> SourceRange(LBracLoc,RBracLoc),
>>                                                   receiverIsId);
>> -      if (Method)
>> +      if (Method) {
>>          if (ObjCMethodDecl *BestMethod =
>>                SelectBestMethod(Sel, ArgsIn, Method->isInstanceMethod()))
>>            Method = BestMethod;
>> +          SmallVector<ObjCMethodDecl*, 4> Methods;
>> +          if (!CollectMultipleMethodsInGlobalPool(Sel, Methods,
>> Method->isInstanceMethod()))
>> +            DiagnoseUseOfDecl(Method, SelLoc);
>> +      }
>>      } else if (ReceiverType->isObjCClassType() ||
>>                 ReceiverType->isObjCQualifiedClassType()) {
>>        // Handle messages to Class.
>>
>> Modified: cfe/trunk/test/ARCMT/checking.m
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/checking.m?rev=221562&r1=221561&r2=221562&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/ARCMT/checking.m (original)
>> +++ cfe/trunk/test/ARCMT/checking.m Fri Nov  7 17:51:15 2014
>> @@ -14,9 +14,9 @@ typedef int BOOL;
>>  typedef unsigned NSUInteger;
>>
>>  @protocol NSObject
>> -- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
>> +- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE; // expected-note
>> {{'retain' has been explicitly marked unavailable here}}
>>  - (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
>> -- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
>> +- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE; //
>> expected-note 4 {{'release' has been explicitly marked unavailable here}}
>>  - (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
>>  @end
>>
>> @@ -74,16 +74,20 @@ id global_foo;
>>
>>  void test1(A *a, BOOL b, struct UnsafeS *unsafeS) {
>>    [[a delegate] release]; // expected-error {{it is not safe to remove
>> 'retain' message on the result of a 'delegate' message; the object that was
>> passed to 'setDelegate:' may not be properly retained}} \
>> +                         // expected-error {{'release' is unavailable:
>> not available in automatic reference counting mode}} \
>>                            // expected-error {{ARC forbids explicit
>> message send}}
>>    [a.delegate release]; // expected-error {{it is not safe to remove
>> 'retain' message on the result of a 'delegate' message; the object that was
>> passed to 'setDelegate:' may not be properly retained}} \
>> +                       // expected-error {{'release' is unavailable: not
>> available in automatic reference counting mode}} \
>>                          // expected-error {{ARC forbids explicit message
>> send}}
>>    [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to
>> remove 'retain' message on an __unsafe_unretained type}} \
>>                                 // expected-error {{ARC forbids explicit
>> message send}} \
>>                                 // expected-error {{'retain' is
>> unavailable}}
>>    id foo = [unsafeS->unsafeObj retain]; // no warning.
>>    [global_foo retain]; // expected-error {{it is not safe to remove
>> 'retain' message on a global variable}} \
>> +                      // expected-error {{'retain' is unavailable: not
>> available in automatic reference counting mode}} \
>>                         // expected-error {{ARC forbids explicit message
>> send}}
>>    [global_foo release]; // expected-error {{it is not safe to remove
>> 'release' message on a global variable}} \
>> +                       // expected-error {{'release' is unavailable: not
>> available in automatic reference counting mode}} \
>>                          // expected-error {{ARC forbids explicit message
>> send}}
>>    [a dealloc];
>>    [a retain];
>> @@ -304,7 +308,8 @@ void rdar9491791(int p) {
>>
>>  // rdar://9504750
>>  void rdar9504750(id p) {
>> -  RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message
>> send of 'release'}}
>> +  RELEASE_MACRO(p); // expected-error {{ARC forbids explicit message
>> send of 'release'}} \
>> +                   // expected-error {{'release' is unavailable: not
>> available in automatic reference counting mode}}
>>  }
>>
>>  // rdar://8939557
>>
>> Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=221562&r1=221561&r2=221562&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
>> +++ cfe/trunk/test/SemaObjC/attr-deprecated.m Fri Nov  7 17:51:15 2014
>> @@ -5,7 +5,7 @@
>>    int X __attribute__((deprecated)); // expected-note 2 {{'X' has been
>> explicitly marked deprecated here}}
>>  }
>>  + (void)F __attribute__((deprecated)); // expected-note 2 {{'F' has been
>> explicitly marked deprecated here}}
>> -- (void)f __attribute__((deprecated)); // expected-note 4 {{'f' has been
>> explicitly marked deprecated here}}
>> +- (void)f __attribute__((deprecated)); // expected-note 5 {{'f' has been
>> explicitly marked deprecated here}}
>>  @end
>>
>>  @implementation A
>> @@ -54,7 +54,7 @@ void t1(A *a)
>>
>>  void t2(id a)
>>  {
>> -  [a f];
>> +  [a f]; // expected-warning {{'f' is deprecated}}
>>  }
>>
>>  void t3(A<P>* a)
>> @@ -228,3 +228,13 @@ expected-note {{property declared here}}
>>
>>  @end
>>
>> +// rdar://18848183
>> + at interface NSString
>> +- (const char *)cString
>> __attribute__((availability(macosx,introduced=10.0
>> ,deprecated=10.4,message="" ))); // expected-note {{'cString' has been
>> explicitly marked deprecated here}}
>> + at end
>> +
>> +id PID = 0;
>> +const char * func() {
>> +  return [PID cString]; // expected-warning {{'cString' is deprecated:
>> first deprecated in OS X 10.4}}
>> +}
>> +
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141212/00117270/attachment.html>


More information about the cfe-commits mailing list