forked from OSchip/llvm-project
Reintroduce r127617: "Code generation for noexcept." with fixes.
llvm-svn: 127685
This commit is contained in:
parent
dbb27393cc
commit
0b94c9fb69
|
@ -449,10 +449,13 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
|
|||
if (Proto == 0)
|
||||
return;
|
||||
|
||||
// FIXME: What about noexcept?
|
||||
if (!Proto->hasDynamicExceptionSpec())
|
||||
return;
|
||||
|
||||
ExceptionSpecificationType EST = Proto->getExceptionSpecType();
|
||||
if (isNoexceptExceptionSpec(EST)) {
|
||||
if (Proto->getNoexceptSpec(getContext()) == FunctionProtoType::NR_Nothrow) {
|
||||
// noexcept functions are simple terminate scopes.
|
||||
EHStack.pushTerminate();
|
||||
}
|
||||
} else if (EST == EST_Dynamic || EST == EST_DynamicNone) {
|
||||
unsigned NumExceptions = Proto->getNumExceptions();
|
||||
EHFilterScope *Filter = EHStack.pushFilter(NumExceptions);
|
||||
|
||||
|
@ -464,6 +467,7 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) {
|
|||
Filter->setFilter(I, EHType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
|
||||
if (!CGM.getLangOptions().CXXExceptions)
|
||||
|
@ -476,11 +480,15 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
|
|||
if (Proto == 0)
|
||||
return;
|
||||
|
||||
if (!Proto->hasDynamicExceptionSpec())
|
||||
return;
|
||||
|
||||
ExceptionSpecificationType EST = Proto->getExceptionSpecType();
|
||||
if (isNoexceptExceptionSpec(EST)) {
|
||||
if (Proto->getNoexceptSpec(getContext()) == FunctionProtoType::NR_Nothrow) {
|
||||
EHStack.popTerminate();
|
||||
}
|
||||
} else if (EST == EST_Dynamic || EST == EST_DynamicNone) {
|
||||
EHStack.popFilter();
|
||||
}
|
||||
}
|
||||
|
||||
void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) {
|
||||
EnterCXXTryStmt(S);
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
|
||||
|
||||
void external();
|
||||
|
||||
void target() throw(int)
|
||||
{
|
||||
// CHECK: invoke void @_Z8externalv()
|
||||
external();
|
||||
}
|
||||
// CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} i8* bitcast (i8** @_ZTIi to i8*), i8* null) nounwind
|
||||
// CHECK: call void @__cxa_call_unexpected
|
|
@ -0,0 +1,18 @@
|
|||
// RUN: %clang_cc1 %s -std=c++0x -triple=x86_64-apple-darwin10 -emit-llvm -o - -fcxx-exceptions -fexceptions | FileCheck %s
|
||||
|
||||
void external();
|
||||
|
||||
void target() noexcept
|
||||
{
|
||||
// CHECK: invoke void @_Z8externalv()
|
||||
external();
|
||||
}
|
||||
// CHECK: call i32 (i8*, i8*, ...)* @llvm.eh.selector({{.*}} i8* null) nounwind
|
||||
// CHECK-NEXT: call void @_ZSt9terminatev() noreturn nounwind
|
||||
// CHECK-NEXT: unreachable
|
||||
|
||||
void reverse() noexcept(false)
|
||||
{
|
||||
// CHECK: call void @_Z8externalv()
|
||||
external();
|
||||
}
|
Loading…
Reference in New Issue