[cfe-commits] r50747 - in /cfe/trunk: Driver/ASTConsumers.cpp include/clang/AST/DeclObjC.h include/clang/Parse/Action.h include/clang/Parse/DeclSpec.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.h lib/Sema/SemaDeclObjC.cpp test/Sema/objc-property-3.m

Fariborz Jahanian fjahanian at apple.com
Tue May 6 11:09:04 PDT 2008


Author: fjahanian
Date: Tue May  6 13:09:04 2008
New Revision: 50747

URL: http://llvm.org/viewvc/llvm-project?rev=50747&view=rev
Log:
Patch to refactor setter/getter names of property attributes into Selector
(was IdentifierInfo * before). This will make method declartations whole
lot easier.

Modified:
    cfe/trunk/Driver/ASTConsumers.cpp
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/DeclSpec.h
    cfe/trunk/lib/Parse/ParseObjc.cpp
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp
    cfe/trunk/test/Sema/objc-property-3.m

Modified: cfe/trunk/Driver/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/ASTConsumers.cpp?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/Driver/ASTConsumers.cpp (original)
+++ cfe/trunk/Driver/ASTConsumers.cpp Tue May  6 13:09:04 2008
@@ -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;
   }
       

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue May  6 13:09:04 2008
@@ -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) {

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Tue May  6 13:09:04 2008
@@ -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;
   }

Modified: cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Parse/DeclSpec.h Tue May  6 13:09:04 2008
@@ -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) 

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Tue May  6 13:09:04 2008
@@ -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);
         }

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue May  6 13:09:04 2008
@@ -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, 

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue May  6 13:09:04 2008
@@ -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)

Modified: cfe/trunk/test/Sema/objc-property-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-property-3.m?rev=50747&r1=50746&r2=50747&view=diff

==============================================================================
--- cfe/trunk/test/Sema/objc-property-3.m (original)
+++ cfe/trunk/test/Sema/objc-property-3.m Tue May  6 13:09:04 2008
@@ -1,15 +0,0 @@
-// RUN: clang -verify %s
-
- at interface I 
-{
-	id d1;
-}
- at property (readwrite, copy) id d1;
- at property (readwrite, copy) id d2;
- at end
-
- at interface NOW : I
- at 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'}}
- at property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match property type inherited from 'I'}}
- at end
-





More information about the cfe-commits mailing list