[cfe-commits] r147468 - in /cfe/trunk: lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaObjCProperty.cpp test/SemaObjC/default-synthesize-3.m

Fariborz Jahanian fjahanian at apple.com
Tue Jan 3 11:46:01 PST 2012


Author: fjahanian
Date: Tue Jan  3 13:46:00 2012
New Revision: 147468

URL: http://llvm.org/viewvc/llvm-project?rev=147468&view=rev
Log:
objc: use objc_suppress_autosynthesis attribute on classes
which should not be default synthesized.

Added:
    cfe/trunk/test/SemaObjC/default-synthesize-3.m
Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=147468&r1=147467&r2=147468&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Jan  3 13:46:00 2012
@@ -1665,9 +1665,10 @@
   // Check and see if properties declared in the interface have either 1)
   // an implementation or 2) there is a @synthesize/@dynamic implementation
   // of the property in the @implementation.
-  if (isa<ObjCInterfaceDecl>(CDecl) &&
-        !(LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2))
-    DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, InsMap);
+  if (const ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(CDecl))
+    if  (!(LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2) ||
+      IDecl->isObjCSuppressAutosynthesis())
+      DiagnoseUnimplementedProperties(S, IMPDecl, CDecl, InsMap);
       
   llvm::DenseSet<Selector> ClsMap;
   for (ObjCImplementationDecl::classmeth_iterator

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=147468&r1=147467&r2=147468&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Jan  3 13:46:00 2012
@@ -856,7 +856,8 @@
     }
     IC->addPropertyImplementation(PIDecl);
     if (getLangOptions().ObjCDefaultSynthProperties &&
-        getLangOptions().ObjCNonFragileABI2) {
+        getLangOptions().ObjCNonFragileABI2 &&
+        !IDecl->isObjCSuppressAutosynthesis()) {
       // Diagnose if an ivar was lazily synthesdized due to a previous
       // use and if 1) property is @dynamic or 2) property is synthesized
       // but it requires an ivar of different name.
@@ -1355,7 +1356,8 @@
   if (!IC)
     return;
   if (ObjCInterfaceDecl* IDecl = IC->getClassInterface())
-    DefaultSynthesizeProperties(S, IC, IDecl);
+    if (!IDecl->isObjCSuppressAutosynthesis())
+      DefaultSynthesizeProperties(S, IC, IDecl);
 }
 
 void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,

Added: cfe/trunk/test/SemaObjC/default-synthesize-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/default-synthesize-3.m?rev=147468&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/default-synthesize-3.m (added)
+++ cfe/trunk/test/SemaObjC/default-synthesize-3.m Tue Jan  3 13:46:00 2012
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify %s
+
+__attribute ((objc_suppress_autosynthesis)) 
+ at interface NoAuto
+ at property int NoAutoProp; // expected-note 2 {{property declared here}}
+ at end
+
+ at implementation NoAuto  // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
+                        // expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
+ at end
+
+__attribute ((objc_suppress_autosynthesis))  // redundant, just for testing
+ at interface Sub : NoAuto 
+ at property (copy) id SubProperty; // expected-note 2 {{property declared here}}
+ at end
+
+ at implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
+                    // expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
+ at end
+
+ at interface Deep : Sub
+ at property (copy) id DeepProperty;
+ at property (copy) id DeepSynthProperty;
+ at property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
+ at end
+
+ at implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
+ at dynamic DeepProperty;
+ at synthesize DeepSynthProperty;
+- (id) DeepMustSynthProperty { return 0; }
+ at end
+





More information about the cfe-commits mailing list