Move handling of @try and @throw to the runtime class.

llvm-svn: 55983
This commit is contained in:
Anders Carlsson 2008-09-09 10:04:29 +00:00
parent 8529085f4f
commit 1963b0c38f
6 changed files with 59 additions and 5 deletions

View 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() {}

View 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);
}

View 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

View 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.

View 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");

View 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