[PATCH] D29967: Get class property setter selector from property decl if exists
David Herzka via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 14 14:33:09 PST 2017
herzka created this revision.
Before this fix, trying to set a class property using dot syntax would always use the constructed name (setX:), which might not match the real selector if the setter is specified via the `setter` property attribute. Now, the setter selector in the declaration has priority over the constructed name, which is consistent with instance properties.
https://reviews.llvm.org/D29967
Files:
lib/Sema/SemaExprObjC.cpp
Index: lib/Sema/SemaExprObjC.cpp
===================================================================
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -2000,10 +2000,16 @@
}
// Look for the matching setter, in case it is needed.
- Selector SetterSel =
- SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
- PP.getSelectorTable(),
- &propertyName);
+ Selector SetterSel;
+ if (ObjCPropertyDecl *PD = IFace->FindPropertyDeclaration(
+ &propertyName, ObjCPropertyQueryKind::OBJC_PR_query_class)) {
+ SetterSel = PD->getSetterName();
+ } else {
+ SetterSel =
+ SelectorTable::constructSetterSelector(PP.getIdentifierTable(),
+ PP.getSelectorTable(),
+ &propertyName);
+ }
ObjCMethodDecl *Setter = IFace->lookupClassMethod(SetterSel);
if (!Setter) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29967.88445.patch
Type: text/x-patch
Size: 988 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170214/c9cbcc20/attachment.bin>
More information about the cfe-commits
mailing list