[PATCH] D36790: [ObjC] Messages to 'self' in class methods that return 'instancetype' should use the pointer to the class as the result type of the message

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 22:14:00 PST 2017


rjmccall added inline comments.


================
Comment at: lib/Sema/SemaExprObjC.cpp:1357
+        (ReceiverType->isObjCClassOrClassKindOfType() ||
+         ReceiverType->isObjCQualifiedClassType()) &&
+        Receiver->isObjCSelfExpr() && getLangOpts().ObjCAutoRefCount) {
----------------
What's the purpose of these two checks?  I believe one of these is required in order to have decided that we're making a class message anyway, and regardless I don't understand why they would affect your logic.

I don't think you should vary the logic here based on whether you're in ARC.  Just assume that the user isn't doing silly stuff like reassigning self to random values.  No, it's not strictly sound, but it's sound enough.


Repository:
  rL LLVM

https://reviews.llvm.org/D36790





More information about the cfe-commits mailing list