]> granicus.if.org Git - clang/commitdiff
This patch fixes the code gen failures which was a fallout from
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 10 Jan 2009 21:06:09 +0000 (21:06 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 10 Jan 2009 21:06:09 +0000 (21:06 +0000)
not merging protocol properties into the classes which
use those protocols. With this patch, all my exceutable
test pass again.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62030 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGObjC.cpp
lib/CodeGen/CGObjCGNU.cpp
lib/CodeGen/CGObjCMac.cpp
lib/CodeGen/CGObjCRuntime.h
lib/CodeGen/CodeGenFunction.h

index 3907c0c2c082a625d40aaf2780a59ce21b7908d4..ef7b142e3c3d07036ffc1f6525fd20c3044870da 100644 (file)
@@ -103,9 +103,10 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E) {
 /// StartObjCMethod - Begin emission of an ObjCMethod. This generates
 /// the LLVM function and sets the other context used by
 /// CodeGenFunction.
-void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD) {
+void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD,
+                                      const ObjCContainerDecl *CD) {
   FunctionArgList Args;
-  llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD);
+  llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD);
 
   CGM.SetMethodAttributes(OMD, Fn);
 
@@ -125,7 +126,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD) {
 /// Generate an Objective-C method.  An Objective-C method is a C function with
 /// its pointer, name, and types registered in the class struture.  
 void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) {
-  StartObjCMethod(OMD);
+  StartObjCMethod(OMD, OMD->getClassInterface());
   EmitStmt(OMD->getBody());
   FinishFunction(cast<CompoundStmt>(OMD->getBody())->getRBracLoc());
 }
@@ -143,12 +144,10 @@ void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP,
   const ObjCPropertyDecl *PD = PID->getPropertyDecl();
   ObjCMethodDecl *OMD = PD->getGetterMethodDecl();
   assert(OMD && "Invalid call to generate getter (empty method)");
-  assert (!dyn_cast<ObjCProtocolDecl>(OMD->getDeclContext()) && 
-          "GenerateObjCMethod - cannot synthesize protocol getter");
   // FIXME: This is rather murky, we create this here since they will
   // not have been created by Sema for us.
   OMD->createImplicitParams(getContext(), IMP->getClassInterface());
-  StartObjCMethod(OMD);
+  StartObjCMethod(OMD, IMP->getClassInterface());
 
   // Determine if we should use an objc_getProperty call for
   // this. Non-atomic properties are directly evaluated.
@@ -215,12 +214,10 @@ void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP,
   const ObjCPropertyDecl *PD = PID->getPropertyDecl();
   ObjCMethodDecl *OMD = PD->getSetterMethodDecl();
   assert(OMD && "Invalid call to generate setter (empty method)");
-  assert (!dyn_cast<ObjCProtocolDecl>(OMD->getDeclContext()) && 
-          "GenerateObjCSetter - cannot synthesize protocol setter");
   // FIXME: This is rather murky, we create this here since they will
   // not have been created by Sema for us.  
   OMD->createImplicitParams(getContext(), IMP->getClassInterface());
-  StartObjCMethod(OMD);
+  StartObjCMethod(OMD, IMP->getClassInterface());
 
   bool IsCopy = PD->getSetterKind() == ObjCPropertyDecl::Copy;
   bool IsAtomic = 
index da1966f77c4380e1dc73e10b7326d7e0884fd5d0..0bf3c2d1b99bfc916e5d463f7e6362f7e322f7ea 100644 (file)
@@ -113,7 +113,8 @@ public:
                                 const ObjCInterfaceDecl *OID);
   virtual llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel);
   
-  virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD);
+  virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD, 
+                                         const ObjCContainerDecl *CD);
   virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD);
   virtual void GenerateClass(const ObjCImplementationDecl *ClassDecl);
   virtual llvm::Value *GenerateProtocolRef(CGBuilderTy &Builder,
@@ -932,7 +933,8 @@ llvm::Function *CGObjCGNU::ModuleInitFunction() {
   return LoadFunction;
 }
 
-llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD) {  
+llvm::Function *CGObjCGNU::GenerateMethod(const ObjCMethodDecl *OMD,
+                                          const ObjCContainerDecl *CD) {  
   const ObjCCategoryImplDecl *OCD = 
     dyn_cast<ObjCCategoryImplDecl>(OMD->getDeclContext());
   std::string CategoryName = OCD ? OCD->getNameAsString() : "";
index 218886fec738de9803852f9ccdfda3ced96cd233..637edf3feae282eae6f97fa3d1681bb47e660b56 100644 (file)
@@ -408,6 +408,7 @@ private:
   /// GetNameForMethod - Return a name for the given method.
   /// \param[out] NameOut - The return value.
   void GetNameForMethod(const ObjCMethodDecl *OMD,
+                        const ObjCContainerDecl *CD,
                         std::string &NameOut);
 
 public:
@@ -435,7 +436,8 @@ public:
 
   virtual llvm::Value *GetSelector(CGBuilderTy &Builder, Selector Sel);
   
-  virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD);
+  virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD,
+                                         const ObjCContainerDecl *CD=0);
 
   virtual void GenerateCategory(const ObjCCategoryImplDecl *CMD);
 
@@ -1434,9 +1436,10 @@ llvm::Constant *CGObjCMac::EmitMethodList(const std::string &Name,
                                         ObjCTypes.MethodListPtrTy);
 }
 
-llvm::Function *CGObjCMac::GenerateMethod(const ObjCMethodDecl *OMD) { 
+llvm::Function *CGObjCMac::GenerateMethod(const ObjCMethodDecl *OMD,
+                                          const ObjCContainerDecl *CD) { 
   std::string Name;
-  GetNameForMethod(OMD, Name);
+  GetNameForMethod(OMD, CD, Name);
 
   const llvm::FunctionType *MethodTy =
     CGM.getTypes().GetFunctionType(CGFunctionInfo(OMD, CGM.getContext()));
@@ -2141,11 +2144,13 @@ llvm::Constant *CGObjCMac::GetPropertyTypeString(const ObjCPropertyDecl *PD,
 }
 
 void CGObjCMac::GetNameForMethod(const ObjCMethodDecl *D, 
+                                 const ObjCContainerDecl *CD,
                                  std::string &NameOut) {
   // FIXME: Find the mangling GCC uses.
   NameOut = (D->isInstanceMethod() ? "-" : "+");
   NameOut += '[';
-  NameOut += D->getClassInterface()->getNameAsString();
+  assert (CD && "Missing container decl in GetNameForMethod");
+  NameOut += CD->getNameAsString();
   NameOut += ' ';
   NameOut += D->getSelector().getAsString();
   NameOut += ']';
index 4241084bf4f95ebd3e1395bd56f44134688f0058..ac50e79fca25a9d24eebe2082c8661eee41466aa 100644 (file)
@@ -39,6 +39,7 @@ namespace CodeGen {
   class ObjCAtTryStmt;
   class ObjCAtThrowStmt;
   class ObjCAtSynchronizedStmt;
+  class ObjCContainerDecl;
   class ObjCCategoryImplDecl;
   class ObjCImplementationDecl;
   class ObjCInterfaceDecl;
@@ -116,7 +117,8 @@ public:
   // really this should also be generating the loads of the
   // parameters, as the runtime should have full control over how
   // parameters are passed.
-  virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD) = 0;
+  virtual llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD, 
+                                         const ObjCContainerDecl *CD) = 0;
 
   /// Return the runtime function for getting properties.
   virtual llvm::Function *GetPropertyGetFunction() = 0;
index 2cba7d03e00e4f683d09ef37481350e0d8610f4b..8437f29faca2850129dcf736708e2ca406c8280c 100644 (file)
@@ -42,6 +42,7 @@ namespace clang {
   class FunctionDecl;
   class FunctionTypeProto;
   class LabelStmt;
+  class ObjCContainerDecl;
   class ObjCInterfaceDecl;
   class ObjCIvarDecl;
   class ObjCMethodDecl;
@@ -184,7 +185,8 @@ public:
 
   void GenerateObjCMethod(const ObjCMethodDecl *OMD);
 
-  void StartObjCMethod(const ObjCMethodDecl *MD);
+  void StartObjCMethod(const ObjCMethodDecl *MD, 
+                       const ObjCContainerDecl *CD);
 
   /// GenerateObjCGetter - Synthesize an Objective-C property getter
   /// function.