]> granicus.if.org Git - clang/commitdiff
Move handling of @try and @throw to the runtime class.
authorAnders Carlsson <andersca@mac.com>
Tue, 9 Sep 2008 10:04:29 +0000 (10:04 +0000)
committerAnders Carlsson <andersca@mac.com>
Tue, 9 Sep 2008 10:04:29 +0000 (10:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55983 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 7242d01adbaa5543b416af981b84ed3c6c5adbba..b5834e68e534a8d119321424da9764cc2b18317e 100644 (file)
@@ -471,4 +471,14 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
   EmitBlock(LoopEnd);
 }
 
+void CodeGenFunction::EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
+{
+  CGM.getObjCRuntime().EmitTryStmt(*this, S);
+}
+
+void CodeGenFunction::EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
+{
+  CGM.getObjCRuntime().EmitThrowStmt(*this, S);
+}
+
 CGObjCRuntime::~CGObjCRuntime() {}
index 2bbbb46cd0b8b0589ebd3474f928df8251741455..2641d9d8bda67ae869c8fa7d6f8efc6e7a57e859 100644 (file)
@@ -122,6 +122,11 @@ public:
   virtual void GenerateProtocol(const ObjCProtocolDecl *PD);
   virtual llvm::Function *ModuleInitFunction();
   virtual llvm::Function *EnumerationMutationFunction();
+  
+  virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
+                           const ObjCAtTryStmt &S);
+  virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
+                             const ObjCAtThrowStmt &S);
 };
 } // end anonymous namespace
 
@@ -967,6 +972,18 @@ llvm::Function *CGObjCGNU::EnumerationMutationFunction()
   return 0;
 }
 
+void CGObjCGNU::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
+                            const ObjCAtTryStmt &S)
+{
+  CGF.ErrorUnsupported(&S, "@try statement");
+}
+
+void CGObjCGNU::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
+                              const ObjCAtThrowStmt &S)
+{
+  CGF.ErrorUnsupported(&S, "@throw statement");
+}
+
 CodeGen::CGObjCRuntime *CodeGen::CreateGNUObjCRuntime(CodeGen::CodeGenModule &CGM){
   return new CGObjCGNU(CGM);
 }
index 26e8c5f5b6d826d02a29cba54315d2220e874176..f0e70978f7bbc3c956eae4ee776f56022d1c5f5a 100644 (file)
@@ -373,6 +373,12 @@ public:
 
   virtual llvm::Function *ModuleInitFunction();
   virtual llvm::Function *EnumerationMutationFunction();
+  
+  virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
+                           const ObjCAtTryStmt &S);
+  virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
+                             const ObjCAtThrowStmt &S);
+  
 };
 } // end anonymous namespace
 
@@ -1392,6 +1398,18 @@ llvm::Function *CGObjCMac::EnumerationMutationFunction()
   return ObjCTypes.EnumerationMutationFn;
 }
 
+void CGObjCMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
+                            const ObjCAtTryStmt &S)
+{
+  CGF.ErrorUnsupported(&S, "@try statement");
+}
+
+void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
+                              const ObjCAtThrowStmt &S)
+{
+  CGF.ErrorUnsupported(&S, "@throw statement");
+}
+
 /* *** Private Interface *** */
 
 /// EmitImageInfo - Emit the image info marker used to encode some module
index 7b00725f23cd60c6186d79401d196cf81564c908..c8efc5263aee365cd8f6d198c0833f7a34914539 100644 (file)
@@ -36,6 +36,8 @@ namespace CodeGen {
   class CodeGenFunction;
 }
 
+  class ObjCAtTryStmt;
+  class ObjCAtThrowStmt;
   class ObjCCategoryImplDecl;
   class ObjCImplementationDecl;
   class ObjCInterfaceDecl;
@@ -130,6 +132,11 @@ public:
   /// the structure.  If this returns true then @defs is invalid for this
   /// runtime and a warning should be generated.
   virtual bool LateBoundIVars() const { return false; }
+
+  virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
+                           const ObjCAtTryStmt &S) = 0;
+  virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
+                             const ObjCAtThrowStmt &S) = 0;
 };
 
 /// Creates an instance of an Objective-C runtime class.  
index b766fe8a64798334df14a082e94e2ef5939b422d..4001be49f8597b7539209c8f180a352d9f4dc619 100644 (file)
@@ -78,16 +78,16 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
   case Stmt::AsmStmtClass:      EmitAsmStmt(cast<AsmStmt>(*S));           break;
 
   case Stmt::ObjCAtTryStmtClass:
-    ErrorUnsupported(S, "@try statement");
-    break;
+    EmitObjCAtTryStmt(cast<ObjCAtTryStmt>(*S));
+    break;    
   case Stmt::ObjCAtCatchStmtClass:
-    ErrorUnsupported(S, "@catch statement");
+    assert(0 && "@catch statements should be handled by EmitObjCAtTryStmt");
     break;
   case Stmt::ObjCAtFinallyStmtClass:
-    ErrorUnsupported(S, "@finally statement");
+    assert(0 && "@finally statements should be handled by EmitObjCAtTryStmt");
     break;
   case Stmt::ObjCAtThrowStmtClass:
-    ErrorUnsupported(S, "@throw statement");
+    EmitObjCAtThrowStmt(cast<ObjCAtThrowStmt>(*S));
     break;
   case Stmt::ObjCAtSynchronizedStmtClass:
     ErrorUnsupported(S, "@synchronized statement");
index 3d14aed4bd4f6e96960e3d67d062f44f4b54731e..95b72a4ed77eba6c538c61e13069b4339fbad1e8 100644 (file)
@@ -242,6 +242,8 @@ public:
   void EmitAsmStmt(const AsmStmt &S);
   
   void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S);
+  void EmitObjCAtTryStmt(const ObjCAtTryStmt &S);
+  void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S);
   
   //===--------------------------------------------------------------------===//
   //                         LValue Expression Emission