From: Anders Carlsson Date: Tue, 9 Sep 2008 10:04:29 +0000 (+0000) Subject: Move handling of @try and @throw to the runtime class. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=64d5d6c5903157c521af496479d06dc26032d718;p=clang Move handling of @try and @throw to the runtime class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55983 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 7242d01adb..b5834e68e5 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -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() {} diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 2bbbb46cd0..2641d9d8bd 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -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); } diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 26e8c5f5b6..f0e70978f7 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -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 diff --git a/lib/CodeGen/CGObjCRuntime.h b/lib/CodeGen/CGObjCRuntime.h index 7b00725f23..c8efc5263a 100644 --- a/lib/CodeGen/CGObjCRuntime.h +++ b/lib/CodeGen/CGObjCRuntime.h @@ -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. diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index b766fe8a64..4001be49f8 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -78,16 +78,16 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::AsmStmtClass: EmitAsmStmt(cast(*S)); break; case Stmt::ObjCAtTryStmtClass: - ErrorUnsupported(S, "@try statement"); - break; + EmitObjCAtTryStmt(cast(*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(*S)); break; case Stmt::ObjCAtSynchronizedStmtClass: ErrorUnsupported(S, "@synchronized statement"); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 3d14aed4bd..95b72a4ed7 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -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