[PATCH] D30174: [Sema][ObjC] Warn about 'performSelector' calls with selectors that return record types

Alex Lorenz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 3 06:44:31 PST 2017

arphaman marked 3 inline comments as done.
arphaman added inline comments.

Comment at: lib/AST/DeclObjC.cpp:987
       unsigned noParams = param_size();
       if (noParams < 1 || noParams > 3)
         family = OMF_None;
ahatanak wrote:
> It seems like this code would set "family" to OMF_None for some of the performSelector functions. For example:
> https://developer.apple.com/reference/objectivec/nsobject/1411637-performselectoronmainthread?language=objc
> https://developer.apple.com/reference/objectivec/nsobject/1417922-performselector?language=objc
> Do those functions belong to the performSelector family of methods?
Good catch! Yes, we should be more inclusive here.

Comment at: lib/Sema/SemaExprObjC.cpp:2280
+    ImpliedMethod =
+        OPT->getInterfaceDecl()->lookupInstanceMethod(SE->getSelector());
+  } else {
ahatanak wrote:
> Do you need to check if OPT->getInterfaceDecl() returns null here? What happens if OPT is id?
You're right, my mistake.

Comment at: lib/Sema/SemaExprObjC.cpp:2499
       checkCocoaAPI(*this, Result);
+    if (Method)
+      checkFoundationAPI(*this, SelLoc, Method, makeArrayRef(Args, NumArgs),
ahatanak wrote:
> I'm not sure why checkFoundationAPI has to be called inside the else statement. Was there a reason you didn't or couldn't move it outside?
We should check for 'super' calls as wells, you're right.



More information about the cfe-commits mailing list