[cfe-commits] r55404 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp

Daniel Dunbar daniel at zuster.org
Tue Aug 26 21:09:39 CDT 2008


Author: ddunbar
Date: Tue Aug 26 21:09:39 2008
New Revision: 55404

URL: http://llvm.org/viewvc/llvm-project?rev=55404&view=rev
Log:
Add addPropertyMethods implementations for
ObjC{Category,Protocol}Decl.
 - No functionality change.

Modified:
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/lib/AST/DeclObjC.cpp

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Tue Aug 26 21:09:39 2008
@@ -625,6 +625,10 @@
   ObjCPropertyDecl **getPropertyDecl() { return PropertyDecl; }
   
   void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
+
+  void addPropertyMethods(ASTContext &Context,
+                          ObjCPropertyDecl* Property,
+                          llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods);
   
   typedef ObjCPropertyDecl * const * classprop_iterator;
   classprop_iterator classprop_begin() const { return PropertyDecl; }
@@ -862,6 +866,10 @@
   ObjCPropertyDecl * const * getPropertyDecl() const { return PropertyDecl; }
   
   void addProperties(ObjCPropertyDecl **Properties, unsigned NumProperties);
+
+  void addPropertyMethods(ASTContext &Context,
+                          ObjCPropertyDecl* Property,
+                          llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods);
   
   ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
   

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=55404&r1=55403&r2=55404&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Tue Aug 26 21:09:39 2008
@@ -402,14 +402,28 @@
   }
 }
 
-/// addPropertyMethods - Goes through list of properties declared in this class
-/// and builds setter/getter method declartions depending on the setter/getter
-/// attributes of the property.
-///
-void ObjCInterfaceDecl::addPropertyMethods(
-       ASTContext &Context,
-       ObjCPropertyDecl *property,
-       llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+static void 
+addPropertyMethods(Decl *D,
+                   ASTContext &Context,
+                   ObjCPropertyDecl *property,
+                   llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+  ObjCMethodDecl *GetterDecl, *SetterDecl;
+
+  if (ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(D)) {
+    GetterDecl = OID->getInstanceMethod(property->getGetterName());
+    if (!property->isReadOnly())
+      SetterDecl = OID->getInstanceMethod(property->getSetterName());
+  } else if (ObjCCategoryDecl *OCD = dyn_cast<ObjCCategoryDecl>(D)) {
+    GetterDecl = OCD->getInstanceMethod(property->getGetterName());
+    if (!property->isReadOnly())
+      SetterDecl = OCD->getInstanceMethod(property->getSetterName());
+  } else {
+    ObjCProtocolDecl *OPD = cast<ObjCProtocolDecl>(D);
+    GetterDecl = OPD->getInstanceMethod(property->getGetterName());
+    if (!property->isReadOnly())
+      SetterDecl = OPD->getInstanceMethod(property->getSetterName());
+  }
+
   // FIXME: The synthesized property we set here is misleading. We
   // almost always synthesize these methods unless the user explicitly
   // provided prototypes (which is odd, but allowed). Sema should be
@@ -417,7 +431,6 @@
   // it is not currently).
 
   // Find the default getter and if one not found, add one.
-  ObjCMethodDecl *GetterDecl = getInstanceMethod(property->getGetterName());
   if (!GetterDecl) {
     // No instance method of same name as property getter name was found.
     // Declare a getter method and add it to the list of methods 
@@ -427,7 +440,7 @@
                              property->getLocation(), 
                              property->getGetterName(), 
                              property->getType(),
-                             this,
+                             D,
                              true, false, true, ObjCMethodDecl::Required);
     insMethods.push_back(GetterDecl);
   }
@@ -438,7 +451,6 @@
     return;
 
   // Find the default setter and if one not found, add one.
-  ObjCMethodDecl *SetterDecl = getInstanceMethod(property->getSetterName());
   if (!SetterDecl) {
     // No instance method of same name as property setter name was found.
     // Declare a setter method and add it to the list of methods 
@@ -448,7 +460,7 @@
                              property->getLocation(), 
                              property->getSetterName(), 
                              Context.VoidTy,
-                             this,
+                             D,
                              true, false, true, ObjCMethodDecl::Required);
     insMethods.push_back(SetterDecl);
 
@@ -466,6 +478,39 @@
   property->setSetterMethodDecl(SetterDecl);
 }
 
+/// addPropertyMethods - Goes through list of properties declared in this class
+/// and builds setter/getter method declartions depending on the setter/getter
+/// attributes of the property.
+///
+void ObjCInterfaceDecl::addPropertyMethods(
+       ASTContext &Context,
+       ObjCPropertyDecl *property,
+       llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+  ::addPropertyMethods(this, Context, property, insMethods);
+}
+
+/// addPropertyMethods - Goes through list of properties declared in this class
+/// and builds setter/getter method declartions depending on the setter/getter
+/// attributes of the property.
+///
+void ObjCCategoryDecl::addPropertyMethods(
+       ASTContext &Context,
+       ObjCPropertyDecl *property,
+       llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+  ::addPropertyMethods(this, Context, property, insMethods);
+}
+
+/// addPropertyMethods - Goes through list of properties declared in this class
+/// and builds setter/getter method declartions depending on the setter/getter
+/// attributes of the property.
+///
+void ObjCProtocolDecl::addPropertyMethods(
+       ASTContext &Context,
+       ObjCPropertyDecl *property,
+       llvm::SmallVector<ObjCMethodDecl*, 32> &insMethods) {
+  ::addPropertyMethods(this, Context, property, insMethods);
+}
+
 /// addProperties - Insert property declaration AST nodes into
 /// ObjCProtocolDecl's PropertyDecl field.
 ///




More information about the cfe-commits mailing list