r198905 - ObjectiveC. 1) Warn when @dynamic (as well as synthesize)
Fariborz Jahanian
fjahanian at apple.com
Thu Jan 9 16:53:48 PST 2014
Author: fjahanian
Date: Thu Jan 9 18:53:48 2014
New Revision: 198905
URL: http://llvm.org/viewvc/llvm-project?rev=198905&view=rev
Log:
ObjectiveC. 1) Warn when @dynamic (as well as synthesize)
property has the naming convention that implies 'ownership'.
2) improve on diagnostic and make it property specific.
3) fix the line number in the case of default property
synthesis. // rdar://15757510
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/arc-decls.m
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=198905&r1=198904&r2=198905&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 9 18:53:48 2014
@@ -703,8 +703,8 @@ def note_atomic_property_fixup_suggest :
def err_atomic_property_nontrivial_assign_op : Error<
"atomic property of reference type %0 cannot have non-trivial assignment"
" operator">;
-def warn_owning_getter_rule : Warning<
- "property's synthesized getter follows Cocoa naming"
+def warn_cocoa_naming_owned_rule : Warning<
+ "property follows Cocoa naming"
" convention for returning 'owned' objects">,
InGroup<DiagGroup<"objc-property-matches-cocoa-ownership-rule">>;
def warn_auto_synthesizing_protocol_property :Warning<
@@ -733,8 +733,8 @@ def warn_property_getter_owning_mismatch
def error_property_setter_ambiguous_use : Error<
"synthesized properties %0 and %1 both claim setter %2 -"
" use of this setter will cause unexpected behavior">;
-def err_ownin_getter_rule : Error<
- "property's synthesized getter follows Cocoa naming"
+def err_cocoa_naming_owned_rule : Error<
+ "property follows Cocoa naming"
" convention for returning 'owned' objects">;
def warn_default_atomic_custom_getter_setter : Warning<
"atomic by default property %0 has a user defined %select{getter|setter}1 "
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=198905&r1=198904&r2=198905&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Jan 9 18:53:48 2014
@@ -1795,9 +1795,6 @@ void Sema::DiagnoseOwningPropertyGetterS
for (ObjCImplementationDecl::propimpl_iterator
i = D->propimpl_begin(), e = D->propimpl_end(); i != e; ++i) {
ObjCPropertyImplDecl *PID = *i;
- if (PID->getPropertyImplementation() != ObjCPropertyImplDecl::Synthesize)
- continue;
-
const ObjCPropertyDecl *PD = PID->getPropertyDecl();
if (PD && !PD->hasAttr<NSReturnsNotRetainedAttr>() &&
!D->getInstanceMethod(PD->getGetterName())) {
@@ -1808,10 +1805,9 @@ void Sema::DiagnoseOwningPropertyGetterS
if (family == OMF_alloc || family == OMF_copy ||
family == OMF_mutableCopy || family == OMF_new) {
if (getLangOpts().ObjCAutoRefCount)
- Diag(PID->getLocation(), diag::err_ownin_getter_rule);
+ Diag(PD->getLocation(), diag::err_cocoa_naming_owned_rule);
else
- Diag(PID->getLocation(), diag::warn_owning_getter_rule);
- Diag(PD->getLocation(), diag::note_property_declare);
+ Diag(PD->getLocation(), diag::warn_cocoa_naming_owned_rule);
}
}
}
Modified: cfe/trunk/test/SemaObjC/arc-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-decls.m?rev=198905&r1=198904&r2=198905&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-decls.m (original)
+++ cfe/trunk/test/SemaObjC/arc-decls.m Thu Jan 9 18:53:48 2014
@@ -51,20 +51,28 @@ void func()
}
// rdar://9157348
+// rdar://15757510
@interface J
- at property (retain) id newFoo; // expected-note {{property declared here}}
- at property (strong) id copyBar; // expected-note {{property declared here}}
- at property (copy) id allocBaz; // expected-note {{property declared here}}
+ at property (retain) id newFoo; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}}
+ at property (strong) id copyBar; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}}
+ at property (copy) id allocBaz; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}}
@property (copy, nonatomic) id new;
+ at property (retain) id newDFoo; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}}
+ at property (strong) id copyDBar; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}}
+ at property (copy) id allocDBaz; // expected-error {{property follows Cocoa naming convention for returning 'owned' objects}}
@end
@implementation J
- at synthesize newFoo; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}}
- at synthesize copyBar; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}}
- at synthesize allocBaz; // expected-error {{property's synthesized getter follows Cocoa naming convention for returning}}
+ at synthesize newFoo;
+ at synthesize copyBar;
+ at synthesize allocBaz;
@synthesize new;
- new {return 0; };
+
+ at dynamic newDFoo;
+ at dynamic copyDBar;
+ at dynamic allocDBaz;
@end
More information about the cfe-commits
mailing list