]> granicus.if.org Git - clang/commitdiff
objc: When issuing warning for missing synthesis for
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 4 Jan 2012 23:16:13 +0000 (23:16 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 4 Jan 2012 23:16:13 +0000 (23:16 +0000)
properties in classes declared with objc_suppress_autosynthesis
attribute, pinpoint location of the said class in a note.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147562 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaObjCProperty.cpp

index 491453ee19461a8a3e955390dd9e2c1b87f17623..1533718ed9f74b4ed8ab3e8b0b6f5c127d106060 100644 (file)
@@ -865,15 +865,16 @@ public:
   }
 
   /// isObjCSuppressAutosynthesis - Checks that a class or one of its super 
-  /// classes must not be auto-synthesized. Returns true if it must not be.
-  bool isObjCSuppressAutosynthesis() const {
+  /// classes must not be auto-synthesized. Returns class decl. if it must not be;
+  /// 0, otherwise.
+  const ObjCInterfaceDecl *isObjCSuppressAutosynthesis() const {
     const ObjCInterfaceDecl *Class = this;
     while (Class) {
       if (Class->hasAttr<ObjCSuppressAutosynthesisAttr>())
-        return true;
+        return Class;
       Class = Class->getSuperClass();
    }
-   return false;
+   return 0;
   }
 
   ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
index d5047506cc98659c679e2934702ac2427cff34a6..d3a726ccc86a82feb4359d9c8998d606acf34d2b 100644 (file)
@@ -379,6 +379,8 @@ def note_implementation_declared : Note<
   "class implementation is declared here">;
 def note_class_declared : Note<
   "class is declared here">;
+def note_suppressed_class_declare : Note<
+  "class with specified objc_suppress_autosynthesis attribute is declared here">;
 def warn_dup_category_def : Warning<
   "duplicate definition of category %1 on interface %0">;
 def err_conflicting_super_class : Error<"conflicting super class name %0">;
index efef7caadccbe8de60d3459a627701c5d6d21359..45c47756347523fb4d39e48a9994e892824587a6 100644 (file)
@@ -1394,6 +1394,11 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
       << Prop->getDeclName() << Prop->getGetterName();
       Diag(Prop->getLocation(),
            diag::note_property_declare);
+      if (LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2)
+        if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(CDecl))
+          if (const ObjCInterfaceDecl *RID = ID->isObjCSuppressAutosynthesis())
+            Diag(RID->getLocation(), diag::note_suppressed_class_declare);
+            
     }
 
     if (!Prop->isReadOnly() && !InsMap.count(Prop->getSetterName())) {
@@ -1404,6 +1409,10 @@ void Sema::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
       << Prop->getDeclName() << Prop->getSetterName();
       Diag(Prop->getLocation(),
            diag::note_property_declare);
+      if (LangOpts.ObjCDefaultSynthProperties && LangOpts.ObjCNonFragileABI2)
+        if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(CDecl))
+          if (const ObjCInterfaceDecl *RID = ID->isObjCSuppressAutosynthesis())
+            Diag(RID->getLocation(), diag::note_suppressed_class_declare);
     }
   }
 }