diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-03-06 15:58:34 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-03-06 15:58:34 +0000 |
commit | 0e23c61c87551d8d6e796d54f99b654a73c67cff (patch) | |
tree | 3b6ec4f86c4ad9e1811aa96c45d099f3532d1dda /clang/lib/Basic/IdentifierTable.cpp | |
parent | 89e36cc04c692d9fdefbc828c9f50153c0a8c63f (diff) | |
download | llvm-0e23c61c87551d8d6e796d54f99b654a73c67cff.zip llvm-0e23c61c87551d8d6e796d54f99b654a73c67cff.tar.gz llvm-0e23c61c87551d8d6e796d54f99b654a73c67cff.tar.bz2 |
[Sema][ObjC] Warn about 'performSelector' calls with selectors
that return record or vector types
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. 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". This
commit adds a new warning that warns when a selector which corresponds to a
method that returns a record type is passed into performSelector.
rdar://12056271
Differential Revision: https://reviews.llvm.org/D30174
llvm-svn: 297019
Diffstat (limited to 'clang/lib/Basic/IdentifierTable.cpp')
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index af424cd9..5caa8a6 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -487,8 +487,10 @@ ObjCMethodFamily Selector::getMethodFamilyImpl(Selector sel) { if (name == "self") return OMF_self; if (name == "initialize") return OMF_initialize; } - - if (name == "performSelector") return OMF_performSelector; + + if (name == "performSelector" || name == "performSelectorInBackground" || + name == "performSelectorOnMainThread") + return OMF_performSelector; // The other method families may begin with a prefix of underscores. while (!name.empty() && name.front() == '_') |