1515
1616#include " clang/AST/Decl.h"
1717#include " clang/AST/DeclBase.h"
18- #include " clang/AST/DeclObjCCommon.h"
1918#include " clang/AST/ExternalASTSource.h"
2019#include " clang/AST/Redeclarable.h"
2120#include " clang/AST/SelectorLocationsKind.h"
@@ -743,6 +742,34 @@ class ObjCPropertyDecl : public NamedDecl {
743742 void anchor () override ;
744743
745744public:
745+ enum PropertyAttributeKind {
746+ OBJC_PR_noattr = 0x00 ,
747+ OBJC_PR_readonly = 0x01 ,
748+ OBJC_PR_getter = 0x02 ,
749+ OBJC_PR_assign = 0x04 ,
750+ OBJC_PR_readwrite = 0x08 ,
751+ OBJC_PR_retain = 0x10 ,
752+ OBJC_PR_copy = 0x20 ,
753+ OBJC_PR_nonatomic = 0x40 ,
754+ OBJC_PR_setter = 0x80 ,
755+ OBJC_PR_atomic = 0x100 ,
756+ OBJC_PR_weak = 0x200 ,
757+ OBJC_PR_strong = 0x400 ,
758+ OBJC_PR_unsafe_unretained = 0x800 ,
759+ // / Indicates that the nullability of the type was spelled with a
760+ // / property attribute rather than a type qualifier.
761+ OBJC_PR_nullability = 0x1000 ,
762+ OBJC_PR_null_resettable = 0x2000 ,
763+ OBJC_PR_class = 0x4000 ,
764+ OBJC_PR_direct = 0x8000
765+ // Adding a property should change NumPropertyAttrsBits
766+ };
767+
768+ enum {
769+ // / Number of bits fitting all the property attributes.
770+ NumPropertyAttrsBits = 16
771+ };
772+
746773 enum SetterKind { Assign, Retain, Copy, Weak };
747774 enum PropertyControl { None, Required, Optional };
748775
@@ -755,8 +782,8 @@ class ObjCPropertyDecl : public NamedDecl {
755782
756783 QualType DeclType;
757784 TypeSourceInfo *DeclTypeSourceInfo;
758- unsigned PropertyAttributes : NumObjCPropertyAttrsBits ;
759- unsigned PropertyAttributesAsWritten : NumObjCPropertyAttrsBits ;
785+ unsigned PropertyAttributes : NumPropertyAttrsBits ;
786+ unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits ;
760787
761788 // \@required/\@optional
762789 unsigned PropertyImplementation : 2 ;
@@ -783,14 +810,15 @@ class ObjCPropertyDecl : public NamedDecl {
783810 ObjCIvarDecl *PropertyIvarDecl = nullptr ;
784811
785812 ObjCPropertyDecl (DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
786- SourceLocation AtLocation, SourceLocation LParenLocation,
787- QualType T, TypeSourceInfo *TSI, PropertyControl propControl)
788- : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation),
789- LParenLoc (LParenLocation), DeclType(T), DeclTypeSourceInfo(TSI),
790- PropertyAttributes(ObjCPropertyAttribute::kind_noattr),
791- PropertyAttributesAsWritten(ObjCPropertyAttribute::kind_noattr),
792- PropertyImplementation(propControl), GetterName(Selector()),
793- SetterName(Selector()) {}
813+ SourceLocation AtLocation, SourceLocation LParenLocation,
814+ QualType T, TypeSourceInfo *TSI,
815+ PropertyControl propControl)
816+ : NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation),
817+ LParenLoc (LParenLocation), DeclType(T), DeclTypeSourceInfo(TSI),
818+ PropertyAttributes(OBJC_PR_noattr),
819+ PropertyAttributesAsWritten(OBJC_PR_noattr),
820+ PropertyImplementation(propControl), GetterName(Selector()),
821+ SetterName(Selector()) {}
794822
795823public:
796824 static ObjCPropertyDecl *Create (ASTContext &C, DeclContext *DC,
@@ -822,52 +850,47 @@ class ObjCPropertyDecl : public NamedDecl {
822850 // / type.
823851 QualType getUsageType (QualType objectType) const ;
824852
825- ObjCPropertyAttribute::Kind getPropertyAttributes () const {
826- return ObjCPropertyAttribute::Kind (PropertyAttributes);
853+ PropertyAttributeKind getPropertyAttributes () const {
854+ return PropertyAttributeKind (PropertyAttributes);
827855 }
828856
829- void setPropertyAttributes (ObjCPropertyAttribute::Kind PRVal) {
857+ void setPropertyAttributes (PropertyAttributeKind PRVal) {
830858 PropertyAttributes |= PRVal;
831859 }
832860
833861 void overwritePropertyAttributes (unsigned PRVal) {
834862 PropertyAttributes = PRVal;
835863 }
836864
837- ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten () const {
838- return ObjCPropertyAttribute::Kind (PropertyAttributesAsWritten);
865+ PropertyAttributeKind getPropertyAttributesAsWritten () const {
866+ return PropertyAttributeKind (PropertyAttributesAsWritten);
839867 }
840868
841- void setPropertyAttributesAsWritten (ObjCPropertyAttribute::Kind PRVal) {
869+ void setPropertyAttributesAsWritten (PropertyAttributeKind PRVal) {
842870 PropertyAttributesAsWritten = PRVal;
843871 }
844872
845873 // Helper methods for accessing attributes.
846874
847875 // / isReadOnly - Return true iff the property has a setter.
848876 bool isReadOnly () const {
849- return (PropertyAttributes & ObjCPropertyAttribute::kind_readonly );
877+ return (PropertyAttributes & OBJC_PR_readonly );
850878 }
851879
852880 // / isAtomic - Return true if the property is atomic.
853881 bool isAtomic () const {
854- return (PropertyAttributes & ObjCPropertyAttribute::kind_atomic );
882+ return (PropertyAttributes & OBJC_PR_atomic );
855883 }
856884
857885 // / isRetaining - Return true if the property retains its value.
858886 bool isRetaining () const {
859- return (PropertyAttributes & (ObjCPropertyAttribute::kind_retain |
860- ObjCPropertyAttribute::kind_strong |
861- ObjCPropertyAttribute::kind_copy));
887+ return (PropertyAttributes &
888+ (OBJC_PR_retain | OBJC_PR_strong | OBJC_PR_copy));
862889 }
863890
864891 bool isInstanceProperty () const { return !isClassProperty (); }
865- bool isClassProperty () const {
866- return PropertyAttributes & ObjCPropertyAttribute::kind_class;
867- }
868- bool isDirectProperty () const {
869- return PropertyAttributes & ObjCPropertyAttribute::kind_direct;
870- }
892+ bool isClassProperty () const { return PropertyAttributes & OBJC_PR_class; }
893+ bool isDirectProperty () const { return PropertyAttributes & OBJC_PR_direct; }
871894
872895 ObjCPropertyQueryKind getQueryKind () const {
873896 return isClassProperty () ? ObjCPropertyQueryKind::OBJC_PR_query_class :
@@ -883,13 +906,13 @@ class ObjCPropertyDecl : public NamedDecl {
883906 // / the property setter. This is only valid if the property has been
884907 // / defined to have a setter.
885908 SetterKind getSetterKind () const {
886- if (PropertyAttributes & ObjCPropertyAttribute::kind_strong )
909+ if (PropertyAttributes & OBJC_PR_strong )
887910 return getType ()->isBlockPointerType () ? Copy : Retain;
888- if (PropertyAttributes & ObjCPropertyAttribute::kind_retain )
911+ if (PropertyAttributes & OBJC_PR_retain )
889912 return Retain;
890- if (PropertyAttributes & ObjCPropertyAttribute::kind_copy )
913+ if (PropertyAttributes & OBJC_PR_copy )
891914 return Copy;
892- if (PropertyAttributes & ObjCPropertyAttribute::kind_weak )
915+ if (PropertyAttributes & OBJC_PR_weak )
893916 return Weak;
894917 return Assign;
895918 }
0 commit comments