Support for code generation of Objective-C top-level language constructs.
Implemented by David Chisnall!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51835 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp
index 1184307..b37b8d3 100644
--- a/lib/CodeGen/ModuleBuilder.cpp
+++ b/lib/CodeGen/ModuleBuilder.cpp
@@ -67,6 +67,24 @@
       
       if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
         Builder->EmitFunction(FD);
+      } else if (isa<ObjCClassDecl>(D)){
+        //Forward declaration.  Only used for type checking.
+      } else if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D)){
+        // Generate Protocol object.
+        Builder->EmitObjCProtocolImplementation(PD);
+      } else if (isa<ObjCCategoryDecl>(D)){
+        //Only used for typechecking.
+      } else if (ObjCCategoryImplDecl *OCD = dyn_cast<ObjCCategoryImplDecl>(D)){
+        // Generate methods, attach to category structure
+        Builder->EmitObjCCategoryImpl(OCD);
+      } else if (ObjCImplementationDecl * OID = 
+          dyn_cast<ObjCImplementationDecl>(D)){
+        // Generate methods, attach to class structure
+        Builder->EmitObjCClassImplementation(OID);
+      } else if (isa<ObjCInterfaceDecl>(D)){
+        // Ignore - generated when the implementation decl is CodeGen'd
+      } else if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D)){
+        Builder->EmitObjCMethod(OMD);
       } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
         if (VD->isFileVarDecl())
           Builder->EmitGlobalVarDeclarator(VD);