[cfe-commits] r61936 - in /cfe/trunk/lib: AST/DeclObjC.cpp Sema/SemaDeclObjC.cpp

Steve Naroff snaroff at apple.com
Thu Jan 8 12:15:03 PST 2009


Author: snaroff
Date: Thu Jan  8 14:15:03 2009
New Revision: 61936

URL: http://llvm.org/viewvc/llvm-project?rev=61936&view=rev
Log:
Removed ObjCContainerDecl::getPropertyMethods()...doesn't belong in the AST.
Moved logic to Sema::ProcessPropertyDecl().

Modified:
    cfe/trunk/lib/AST/DeclObjC.cpp
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Jan  8 14:15:03 2009
@@ -449,78 +449,6 @@
   return sum;
 }
 
-/// 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 ObjCContainerDecl::getPropertyMethods(
-       ASTContext &Context, ObjCPropertyDecl *property,
-       ObjCMethodDecl *& GetterDecl, ObjCMethodDecl *&SetterDecl) {
-  // 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
-  // typechecking that the declarations jive in that situation (which
-  // it is not currently).
-
-  // Find the default getter and if one not found, add one.
-  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 
-    // for this class.
-    GetterDecl = 
-      ObjCMethodDecl::Create(Context, property->getLocation(), 
-                             property->getLocation(), 
-                             property->getGetterName(), 
-                             property->getType(), this,
-                             true, false, true, 
-                             (property->getPropertyImplementation() == 
-                              ObjCPropertyDecl::Optional) ? 
-                             ObjCMethodDecl::Optional : 
-                             ObjCMethodDecl::Required);
-  }
-  else
-    // A user declared getter will be synthesize when @synthesize of
-    // the property with the same name is seen in the @implementation
-    GetterDecl->setIsSynthesized();
-  property->setGetterMethodDecl(GetterDecl);
-
-  // Skip setter if property is read-only.
-  if (property->isReadOnly())
-    return;
-
-  // Find the default setter and if one not found, add one.
-  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 
-    // for this class.
-    SetterDecl =
-      ObjCMethodDecl::Create(Context, property->getLocation(), 
-                             property->getLocation(), 
-                             property->getSetterName(), 
-                             Context.VoidTy, this,
-                             true, false, true,
-                             (property->getPropertyImplementation() == 
-                              ObjCPropertyDecl::Optional) ? 
-                             ObjCMethodDecl::Optional : 
-                             ObjCMethodDecl::Required);
-    // Invent the arguments for the setter. We don't bother making a
-    // nice name for the argument.
-    ParmVarDecl *Argument = ParmVarDecl::Create(Context, 
-                                               SetterDecl,
-                                               SourceLocation(), 
-                                               property->getIdentifier(),
-                                               property->getType(),
-                                               VarDecl::None,
-                                               0, 0);
-    SetterDecl->setMethodParams(&Argument, 1);
-  }
-  else
-    // A user declared setter will be synthesize when @synthesize of
-    // the property with the same name is seen in the @implementation
-    SetterDecl->setIsSynthesized();
-  property->setSetterMethodDecl(SetterDecl);
-}
-
 /// mergeProperties - Adds properties to the end of list of current properties
 /// for this category.
 

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Jan  8 14:15:03 2009
@@ -1037,6 +1037,54 @@
   }
 
   // Synthesize getter/setter methods if none exist.
+  // Find the default getter and if one not found, add one.
+  if (!GetterMethod) {
+    // No instance method of same name as property getter name was found.
+    // Declare a getter method and add it to the list of methods 
+    // for this class.
+    GetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(), 
+                             property->getLocation(), property->getGetterName(), 
+                             property->getType(), CD, true, false, true, 
+                             (property->getPropertyImplementation() == 
+                              ObjCPropertyDecl::Optional) ? 
+                             ObjCMethodDecl::Optional : 
+                             ObjCMethodDecl::Required);
+  } else
+    // A user declared getter will be synthesize when @synthesize of
+    // the property with the same name is seen in the @implementation
+    GetterMethod->setIsSynthesized();
+  property->setGetterMethodDecl(GetterMethod);
+
+  // Skip setter if property is read-only.
+  if (!property->isReadOnly()) {
+    // Find the default setter and if one not found, add one.
+    if (!SetterMethod) {
+      // No instance method of same name as property setter name was found.
+      // Declare a setter method and add it to the list of methods 
+      // for this class.
+      SetterMethod = ObjCMethodDecl::Create(Context, property->getLocation(), 
+                               property->getLocation(), 
+                               property->getSetterName(), 
+                               Context.VoidTy, CD, true, false, true,
+                               (property->getPropertyImplementation() == 
+                                ObjCPropertyDecl::Optional) ? 
+                               ObjCMethodDecl::Optional : 
+                               ObjCMethodDecl::Required);
+      // Invent the arguments for the setter. We don't bother making a
+      // nice name for the argument.
+      ParmVarDecl *Argument = ParmVarDecl::Create(Context, SetterMethod,
+                                                  SourceLocation(), 
+                                                  property->getIdentifier(),
+                                                  property->getType(),
+                                                  VarDecl::None,
+                                                  0, 0);
+      SetterMethod->setMethodParams(&Argument, 1);
+    } else
+      // A user declared setter will be synthesize when @synthesize of
+      // the property with the same name is seen in the @implementation
+      SetterMethod->setIsSynthesized();
+    property->setSetterMethodDecl(SetterMethod);
+  }
   // Add any synthesized methods to the global pool. This allows us to 
   // handle the following, which is supported by GCC (and part of the design).
   //
@@ -1049,7 +1097,11 @@
   //   double bar = [foo bar];
   // }
   //
-  CD->getPropertyMethods(Context, property, GetterMethod, SetterMethod);
+  // 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
+  // typechecking that the declarations jive in that situation (which
+  // it is not currently).
   if (GetterMethod) {
     CD->addDecl(Context, GetterMethod);
     AddInstanceMethodToGlobalPool(GetterMethod);  





More information about the cfe-commits mailing list