From 9d4d20af55180abca1ecbcebb0710b08d386d281 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 3 Jan 2012 18:45:41 +0000 Subject: [PATCH] objc: introduce objc_suppress_autosynthesis class attributes for later use. llvm-svn: 147457 --- clang/include/clang/AST/DeclObjC.h | 12 ++++++++++++ clang/include/clang/Basic/Attr.td | 4 ++++ clang/include/clang/Sema/AttributeList.h | 1 + clang/lib/Sema/AttributeList.cpp | 1 + clang/lib/Sema/SemaDeclAttr.cpp | 15 +++++++++++++++ 5 files changed, 33 insertions(+) diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 7837b2b2f2a5..491453ee1946 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -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()) + return true; + Class = Class->getSuperClass(); + } + return false; + } + ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared); ObjCIvarDecl *lookupInstanceVariable(IdentifierInfo *IVarName) { diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 0839df8baf72..bf9a6ce147f9 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -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"]; } diff --git a/clang/include/clang/Sema/AttributeList.h b/clang/include/clang/Sema/AttributeList.h index 0c64e2c48723..a0d7c4a56564 100644 --- a/clang/include/clang/Sema/AttributeList.h +++ b/clang/include/clang/Sema/AttributeList.h @@ -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, diff --git a/clang/lib/Sema/AttributeList.cpp b/clang/lib/Sema/AttributeList.cpp index 13a0edec28d6..a8ccbb1f5680 100644 --- a/clang/lib/Sema/AttributeList.cpp +++ b/clang/lib/Sema/AttributeList.cpp @@ -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) diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 1626bf14b604..4074afee1cc6 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -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);