r174775 - objective-C: don't issue bogus warning about
Fariborz Jahanian
fjahanian at apple.com
Fri Feb 8 15:32:30 PST 2013
Author: fjahanian
Date: Fri Feb 8 17:32:30 2013
New Revision: 174775
URL: http://llvm.org/viewvc/llvm-project?rev=174775&view=rev
Log:
objective-C: don't issue bogus warning about
"auto-synthesized may not work correctly with 'nib' loader"
when 'readonly' property is redeclared 'readwrite' in class
extension. // rdar://13123861
Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/iboutlet.m
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=174775&r1=174774&r2=174775&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Fri Feb 8 17:32:30 2013
@@ -839,22 +839,40 @@ Decl *Sema::ActOnPropertyImplDecl(Scope
return 0;
}
}
-
if (Synthesize&&
(PIkind & ObjCPropertyDecl::OBJC_PR_readonly) &&
property->hasAttr<IBOutletAttr>() &&
!AtLoc.isValid()) {
- Diag(IC->getLocation(), diag::warn_auto_readonly_iboutlet_property);
- Diag(property->getLocation(), diag::note_property_declare);
- SourceLocation readonlyLoc;
- if (LocPropertyAttribute(Context, "readonly",
- property->getLParenLoc(), readonlyLoc)) {
- SourceLocation endLoc =
- readonlyLoc.getLocWithOffset(strlen("readonly")-1);
- SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
- Diag(property->getLocation(),
- diag::note_auto_readonly_iboutlet_fixup_suggest) <<
- FixItHint::CreateReplacement(ReadonlySourceRange, "readwrite");
+ bool ReadWriteProperty = false;
+ // Search into the class extensions and see if 'readonly property is
+ // redeclared 'readwrite', then no warning is to be issued.
+ for (ObjCInterfaceDecl::known_extensions_iterator
+ Ext = IDecl->known_extensions_begin(),
+ ExtEnd = IDecl->known_extensions_end(); Ext != ExtEnd; ++Ext) {
+ DeclContext::lookup_result R = Ext->lookup(property->getDeclName());
+ if (!R.empty())
+ if (ObjCPropertyDecl *ExtProp = dyn_cast<ObjCPropertyDecl>(R[0])) {
+ PIkind = ExtProp->getPropertyAttributesAsWritten();
+ if (PIkind & ObjCPropertyDecl::OBJC_PR_readwrite) {
+ ReadWriteProperty = true;
+ break;
+ }
+ }
+ }
+
+ if (!ReadWriteProperty) {
+ Diag(IC->getLocation(), diag::warn_auto_readonly_iboutlet_property);
+ Diag(property->getLocation(), diag::note_property_declare);
+ SourceLocation readonlyLoc;
+ if (LocPropertyAttribute(Context, "readonly",
+ property->getLParenLoc(), readonlyLoc)) {
+ SourceLocation endLoc =
+ readonlyLoc.getLocWithOffset(strlen("readonly")-1);
+ SourceRange ReadonlySourceRange(readonlyLoc, endLoc);
+ Diag(property->getLocation(),
+ diag::note_auto_readonly_iboutlet_fixup_suggest) <<
+ FixItHint::CreateReplacement(ReadonlySourceRange, "readwrite");
+ }
}
}
Modified: cfe/trunk/test/SemaObjC/iboutlet.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/iboutlet.m?rev=174775&r1=174774&r2=174775&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/iboutlet.m (original)
+++ cfe/trunk/test/SemaObjC/iboutlet.m Fri Feb 8 17:32:30 2013
@@ -21,3 +21,24 @@
@implementation I // expected-warning 3 {{readonly IBOutlet property when auto-synthesized may not work correctly with 'nib' loader}}
@end
+
+
+// rdar://13123861
+ at class UILabel;
+
+ at interface NSObject @end
+
+ at interface RKTFHView : NSObject
+ at property( readonly ) __attribute__((iboutlet)) UILabel *autoReadOnlyReadOnly; // expected-note {{property declared here}} expected-note {{readonly IBOutlet property should be changed to be readwrite}}
+ at property( readonly ) __attribute__((iboutlet)) UILabel *autoReadOnlyReadWrite;
+ at property( readonly ) __attribute__((iboutlet)) UILabel *synthReadOnlyReadWrite;
+ at end
+
+ at interface RKTFHView()
+ at property( readwrite ) __attribute__((iboutlet)) UILabel *autoReadOnlyReadWrite;
+ at property( readwrite ) __attribute__((iboutlet)) UILabel *synthReadOnlyReadWrite;
+ at end
+
+ at implementation RKTFHView // expected-warning {{readonly IBOutlet property when auto-synthesized may not work correctly with 'nib' loader}}
+ at synthesize synthReadOnlyReadWrite=_synthReadOnlyReadWrite;
+ at end
More information about the cfe-commits
mailing list