aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/NSAPI.h
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-06-08 21:14:25 +0000
committerJordan Rose <jordan_rose@apple.com>2012-06-08 21:14:25 +0000
commit9f63a451b1b3e36c0c82fcfe78828182bb9a6fa0 (patch)
treec4a00296a42e178095f01242bb38117060909453 /include/clang/AST/NSAPI.h
parent3772c9abf9651da1f77c83ec937c96e10a353c6a (diff)
downloadclang-9f63a451b1b3e36c0c82fcfe78828182bb9a6fa0.tar.gz
Disallow using ObjC literals in direct comparisons (== and friends).
Objective-C literals conceptually always create new objects, but may be optimized by the compiler or runtime (constant folding, singletons, etc). Comparing addresses of these objects is relying on this optimization behavior, which is really an implementation detail. In the case of == and !=, offer a fixit to a call to -isEqual:, if the method is available. This fixit is directly on the error so that it is automatically applied. Most of the time, this is really a newbie mistake, hence the fixit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/NSAPI.h')
-rw-r--r--include/clang/AST/NSAPI.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/clang/AST/NSAPI.h b/include/clang/AST/NSAPI.h
index ec5e542f72..51ae1daf14 100644
--- a/include/clang/AST/NSAPI.h
+++ b/include/clang/AST/NSAPI.h
@@ -132,6 +132,11 @@ public:
return getOrInitSelector(Ids, setObjectAtIndexedSubscriptSel);
}
+ /// \brief Returns selector for "isEqual:".
+ Selector getIsEqualSelector() const {
+ return getOrInitSelector(StringRef("isEqual"), isEqualSel);
+ }
+
/// \brief Enumerates the NSNumber methods used to generate literals.
enum NSNumberLiteralMethodKind {
NSNumberWithChar,
@@ -203,7 +208,8 @@ private:
mutable Selector NSNumberInstanceSelectors[NumNSNumberLiteralMethods];
mutable Selector objectForKeyedSubscriptSel, objectAtIndexedSubscriptSel,
- setObjectForKeyedSubscriptSel,setObjectAtIndexedSubscriptSel;
+ setObjectForKeyedSubscriptSel,setObjectAtIndexedSubscriptSel,
+ isEqualSel;
mutable IdentifierInfo *BOOLId, *NSIntegerId, *NSUIntegerId;
mutable IdentifierInfo *NSASCIIStringEncodingId, *NSUTF8StringEncodingId;