}
static llvm::Constant *getBeginCatchFn(CodeGenModule &CGM) {
+ if (CGM.getTarget().getCXXABI().isMicrosoft())
+ return CGM.getIntrinsic(llvm::Intrinsic::eh_begincatch);
+
// void *__cxa_begin_catch(void*);
llvm::FunctionType *FTy =
}
static llvm::Constant *getEndCatchFn(CodeGenModule &CGM) {
+ if (CGM.getTarget().getCXXABI().isMicrosoft())
+ return CGM.getIntrinsic(llvm::Intrinsic::eh_endcatch);
+
// void __cxa_end_catch();
llvm::FunctionType *FTy =
if (CGM.getLangOpts().CPlusPlus &&
CGM.getTarget().getCXXABI().isItaniumFamily()) {
name = "_ZSt9terminatev";
+ } else if (CGM.getLangOpts().CPlusPlus &&
+ CGM.getTarget().getCXXABI().isMicrosoft()) {
+ name = "\01?terminate@@YAXXZ";
} else if (CGM.getLangOpts().ObjC1 &&
- CGM.getLangOpts().ObjCRuntime.hasTerminate())
+ CGM.getLangOpts().ObjCRuntime.hasTerminate())
name = "objc_terminate";
else
name = "abort";
}
if (CGM.getTarget().getTriple().isKnownWindowsMSVCEnvironment()) {
- ErrorUnsupported(E, "throw expression");
+ // Call std::terminate().
+ llvm::CallInst *TermCall = EmitNounwindRuntimeCall(getTerminateFn(CGM));
+ TermCall->setDoesNotReturn();
+
+ // throw is an expression, and the expression emitters expect us
+ // to leave ourselves at a valid insertion point.
+ if (KeepInsertionPoint)
+ EmitBlock(createBasicBlock("throw.cont"));
+
return;
}
}
void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) {
- if (CGM.getTarget().getTriple().isKnownWindowsMSVCEnvironment()) {
- ErrorUnsupported(&S, "try statement");
- return;
- }
-
EnterCXXTryStmt(S);
EmitStmt(S.getTryBlock());
ExitCXXTryStmt(S);
-// RUN: %clang_cc1 -emit-llvm-only %s -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -verify -DTRY
-// RUN: %clang_cc1 -emit-llvm-only %s -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -verify -DTHROW
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTRY | FileCheck %s -check-prefix=TRY
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -mconstructor-aliases -fcxx-exceptions -fexceptions -fno-rtti -DTHROW | FileCheck %s -check-prefix=THROW
void external();
int main() {
int rv = 0;
#ifdef TRY
- try { // expected-error {{cannot compile this try statement yet}}
- external();
+ try {
+ external(); // TRY: invoke void @"\01?external@@YAXXZ"
} catch (int) {
rv = 1;
+ // TRY: call i8* @llvm.eh.begincatch
+ // TRY: call void @llvm.eh.endcatch
}
#endif
#ifdef THROW
- throw int(42); // expected-error {{cannot compile this throw expression yet}}
+ // THROW: call void @"\01?terminate@@YAXXZ"
+ throw int(42);
#endif
return rv;
}