]> granicus.if.org Git - clang/commitdiff
objc: introduce objc_suppress_autosynthesis class
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Jan 2012 18:45:41 +0000 (18:45 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Jan 2012 18:45:41 +0000 (18:45 +0000)
attributes for later use.

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

include/clang/AST/DeclObjC.h
include/clang/Basic/Attr.td
include/clang/Sema/AttributeList.h
lib/Sema/AttributeList.cpp
lib/Sema/SemaDeclAttr.cpp

index 7837b2b2f2a50bd20c0fa9ce25d23af95b0a1381..491453ee19461a8a3e955390dd9e2c1b87f17623 100644 (file)
@@ -864,6 +864,18 @@ public:
    return false;
   }
 
+  /// 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 {
+    const ObjCInterfaceDecl *Class = this;
+    while (Class) {
+      if (Class->hasAttr<ObjCSuppressAutosynthesisAttr>())
+        return true;
+      Class = Class->getSuperClass();
+   }
+   return false;
+  }
+
   ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName,
                                        ObjCInterfaceDecl *&ClassDeclared);
   ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) {
index 0839df8baf72d519de6ba2a5b37639a1ae2d4596..bf9a6ce147f907cda041cedbdad499619901f7bd 100644 (file)
@@ -524,6 +524,10 @@ def ArcWeakrefUnavailable : InheritableAttr {
   let Spellings = ["objc_arc_weak_reference_unavailable"];
 }
 
+def ObjCSuppressAutosynthesis : InheritableAttr {
+  let Spellings = ["objc_suppress_autosynhesis"];
+}
+
 def Unused : InheritableAttr {
   let Spellings = ["unused"];
 }
index 0c64e2c48723222836c11b360931622796e7db04..a0d7c4a56564324b3240350924b6b5eea678333c 100644 (file)
@@ -169,6 +169,7 @@ public:
     AT_analyzer_noreturn,
     AT_annotate,
     AT_arc_weakref_unavailable,
+    AT_objc_suppress_autosynthesis,
     AT_availability,      // Clang-specific
     AT_base_check,
     AT_blocks,
index 13a0edec28d66fd17da77ee71999a3a8d7a70242..a8ccbb1f5680f7250001e2e7af43df63a39c4388 100644 (file)
@@ -108,6 +108,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) {
     .Case("weak", AT_weak)
     .Case("weakref", AT_weakref)
     .Case("objc_arc_weak_reference_unavailable", AT_arc_weakref_unavailable)
+    .Case("objc_suppress_autosynthesis", AT_objc_suppress_autosynthesis)
     .Case("pure", AT_pure)
     .Case("mode", AT_mode)
     .Case("used", AT_used)
index 1626bf14b604e1788f07ee20ed2ca27fed0269d9..4074afee1cc659aabcfcc623f920cb473b24b0f6 100644 (file)
@@ -1579,6 +1579,18 @@ static void handleArcWeakrefUnavailableAttr(Sema &S, Decl *D,
                                           Attr.getRange(), S.Context));
 }
 
+static void handleObjCSuppressAutosynthesisAttr(Sema &S, Decl *D, 
+                                            const AttributeList &Attr) {
+  unsigned NumArgs = Attr.getNumArgs();
+  if (NumArgs > 0) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments) << 0;
+    return;
+  }
+  
+  D->addAttr(::new (S.Context) ObjCSuppressAutosynthesisAttr(
+                                 Attr.getRange(), S.Context));
+}
+
 static void handleAvailabilityAttr(Sema &S, Decl *D,
                                    const AttributeList &Attr) {
   IdentifierInfo *Platform = Attr.getParameterName();
@@ -3603,6 +3615,9 @@ static void ProcessInheritableDeclAttr(Sema &S, Scope *scope, Decl *D,
   case AttributeList::AT_arc_weakref_unavailable: 
     handleArcWeakrefUnavailableAttr (S, D, Attr); 
     break;
+  case AttributeList::AT_objc_suppress_autosynthesis: 
+    handleObjCSuppressAutosynthesisAttr (S, D, Attr); 
+    break;
   case AttributeList::AT_unused:      handleUnusedAttr      (S, D, Attr); break;
   case AttributeList::AT_returns_twice:
     handleReturnsTwiceAttr(S, D, Attr);