[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
Mon Feb 20 10:29:26 PST 2017


arphaman created this revision.

The `performSelector` family of methods from Foundation use `objc_msgSend` to dispatch the selector invocations to objects. However, method calls to methods that return record types might have to use the `objc_msgSend_stret` as the return value won't find into the register [1]. This is also supported by this sentence from `performSelector` documentation: "The method should not have a significant return value and should take a single argument of type id, or no arguments" [2]. This patch adds a new warning that warns when a selector which corresponds to a method that returns a record type is passed into `performSelector`.

[1] http://www.tomdalling.com/blog/cocoa/why-performselector-is-more-dangerous-than-i-thought/
[2] https://developer.apple.com/reference/objectivec/nsobject/1416176-performselector?language=objc


Repository:
  rL LLVM

https://reviews.llvm.org/D30174

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclObjC.cpp
  lib/Basic/IdentifierTable.cpp
  lib/Sema/SemaExprObjC.cpp
  test/SemaObjC/unsafe-perform-selector.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30174.89132.patch
Type: text/x-patch
Size: 6923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170220/002dfdd8/attachment.bin>


More information about the cfe-commits mailing list