[PATCH] D30174: [Sema][ObjC] Warn about 'performSelector' calls with selectors that return record types
Akira Hatanaka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 21 23:36:00 PST 2017
ahatanak added a comment.
I'm not sure how common it is to pass a function that doesn't return an object or void, I think it's OK to allow returning primitive types if you think being too strict would catch too many false positives.
================
Comment at: lib/AST/DeclObjC.cpp:987
unsigned noParams = param_size();
if (noParams < 1 || noParams > 3)
family = OMF_None;
----------------
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?
================
Comment at: lib/Sema/SemaExprObjC.cpp:2280
+ ImpliedMethod =
+ OPT->getInterfaceDecl()->lookupInstanceMethod(SE->getSelector());
+ } else {
----------------
Do you need to check if OPT->getInterfaceDecl() returns null here? What happens if OPT is id?
================
Comment at: lib/Sema/SemaExprObjC.cpp:2499
checkCocoaAPI(*this, Result);
+ if (Method)
+ checkFoundationAPI(*this, SelLoc, Method, makeArrayRef(Args, NumArgs),
----------------
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?
Repository:
rL LLVM
https://reviews.llvm.org/D30174
More information about the cfe-commits
mailing list