Patch to refactor setter/getter names of property attributes into Selector
(was IdentifierInfo * before). This will make method declartations whole
lot easier.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50747 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/ASTConsumers.cpp b/Driver/ASTConsumers.cpp
index 20d4ce2..45b2ad2 100644
--- a/Driver/ASTConsumers.cpp
+++ b/Driver/ASTConsumers.cpp
@@ -337,12 +337,12 @@
       
   if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
     Out << (first ? ' ' : ',') << "getter = "
-    << PDecl->getGetterName()->getName();
+    << PDecl->getGetterName().getName();
     first = false;
   }
   if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_setter) {
     Out << (first ? ' ' : ',') << "setter = "
-    << PDecl->getSetterName()->getName();
+    << PDecl->getSetterName().getName();
     first = false;
   }
       
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 7947b3d..509f0e0 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -1075,12 +1075,13 @@
   // @required/@optional
   unsigned PropertyImplementation : 2;
   
-  IdentifierInfo *GetterName;    // getter name of NULL if no getter
-  IdentifierInfo *SetterName;    // setter name of NULL if no setter
+  Selector GetterName;    // getter name of NULL if no getter
+  Selector SetterName;    // setter name of NULL if no setter
   
   ObjCPropertyDecl(SourceLocation L, IdentifierInfo *Id, QualType T)
     : NamedDecl(ObjCProperty, L, Id), DeclType(T),
-      PropertyAttributes(OBJC_PR_noattr), GetterName(0), SetterName(0) {}
+      PropertyAttributes(OBJC_PR_noattr), GetterName(Selector()), 
+      SetterName(Selector()) {}
 public:
   static ObjCPropertyDecl *Create(ASTContext &C, SourceLocation L, 
                                   IdentifierInfo *Id, QualType T,
@@ -1095,11 +1096,11 @@
     PropertyAttributes |= PRVal;
   }
   
-  IdentifierInfo *getGetterName() const { return GetterName; }
-  void setGetterName(IdentifierInfo *Id) { GetterName = Id; }
+  Selector getGetterName() const { return GetterName; }
+  void setGetterName(Selector Sel) { GetterName = Sel; }
   
-  IdentifierInfo *getSetterName() const { return SetterName; }
-  void setSetterName(IdentifierInfo *Id) { SetterName = Id; }
+  Selector getSetterName() const { return SetterName; }
+  void setSetterName(Selector Sel) { SetterName = Sel; }
   
   // Related to @optional/@required declared in @protocol
   void setPropertyImplementation(PropertyControl pc) {
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h
index 5d094ae..17899d4 100644
--- a/include/clang/Parse/Action.h
+++ b/include/clang/Parse/Action.h
@@ -686,6 +686,7 @@
   // ActOnProperty - called to build one property AST
   virtual DeclTy *ActOnProperty (Scope *S, SourceLocation AtLoc,
                                  FieldDeclarator &FD, ObjCDeclSpec &ODS,
+                                 Selector GetterSel, Selector SetterSel,
                                  tok::ObjCKeywordKind MethodImplKind) {
     return 0;
   }
diff --git a/include/clang/Parse/DeclSpec.h b/include/clang/Parse/DeclSpec.h
index 4bd6204..369aca4 100644
--- a/include/clang/Parse/DeclSpec.h
+++ b/include/clang/Parse/DeclSpec.h
@@ -329,7 +329,8 @@
   };
   
   
-  ObjCDeclSpec() : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr) 
+  ObjCDeclSpec() : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
+  GetterName(0), SetterName(0)
   {}
   ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; }
   void setObjCDeclQualifier(ObjCDeclQualifier DQVal) 
diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp
index 8d404a9..1ff5877 100644
--- a/lib/Parse/ParseObjc.cpp
+++ b/lib/Parse/ParseObjc.cpp
@@ -270,8 +270,13 @@
         for (unsigned i = 0, e = FieldDeclarators.size(); i != e; ++i) {
           FieldDeclarator &FD = FieldDeclarators[i];
           // Install the property declarator into interfaceDecl.
+          Selector GetterSel = 
+            PP.getSelectorTable().getNullarySelector(OCDS.getGetterName());
+          Selector SetterSel = 
+          PP.getSelectorTable().getNullarySelector(OCDS.getSetterName());
           DeclTy *Property = Actions.ActOnProperty(CurScope,
                                DS.getSourceRange().getBegin(), FD, OCDS,
+                               GetterSel, SetterSel,
                                MethodImplKind);
           allProperties.push_back(Property);
         }
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 5541808..27eca89 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -677,6 +677,7 @@
   
   virtual DeclTy *ActOnProperty(Scope *S, SourceLocation AtLoc,
                                 FieldDeclarator &FD, ObjCDeclSpec &ODS,
+                                Selector GetterSel, Selector SetterSel,
                                 tok::ObjCKeywordKind MethodImplKind);
   
   virtual DeclTy *ActOnPropertyImplDecl(SourceLocation AtLoc, 
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 3b48810..f9e4f5b 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1023,6 +1023,8 @@
 Sema::DeclTy *Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, 
                                   FieldDeclarator &FD,
                                   ObjCDeclSpec &ODS,
+                                  Selector GetterSel,
+                                  Selector SetterSel,
                                   tok::ObjCKeywordKind MethodImplKind) {
   QualType T = GetTypeForDeclarator(FD.D, S);
   ObjCPropertyDecl *PDecl = ObjCPropertyDecl::Create(Context, AtLoc, 
@@ -1033,12 +1035,12 @@
   
   if (ODS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_getter) {
     PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_getter);
-    PDecl->setGetterName(ODS.getGetterName());
+    PDecl->setGetterName(GetterSel);
   }
   
   if (ODS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_setter) {
     PDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_setter);
-    PDecl->setSetterName(ODS.getSetterName());
+    PDecl->setSetterName(SetterSel);
   }
   
   if (ODS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_assign)
diff --git a/test/Sema/objc-property-3.m b/test/Sema/objc-property-3.m
index dd45ab4..e69de29 100644
--- a/test/Sema/objc-property-3.m
+++ b/test/Sema/objc-property-3.m
@@ -1,15 +0,0 @@
-// RUN: clang -verify %s
-
-@interface I 
-{
-	id d1;
-}
-@property (readwrite, copy) id d1;
-@property (readwrite, copy) id d2;
-@end
-
-@interface NOW : I
-@property (readonly, retain) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of property inherited from 'I'}} expected-warning {{property 'd1' 'copy' attribute does not match the property inherited from'I'}}
-@property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match property type inherited from 'I'}}
-@end
-