From a994ee4b197554282ae6b222c3284ccaa3a6484c Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 6 Feb 2010 23:59:05 +0000 Subject: [PATCH] Make EmitStartEHSpec and EmitEndEHSpec return early when exceptions are disabled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95509 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGException.cpp | 6 ++++++ test/CodeGenCXX/no-exceptions.cpp | 12 ++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 test/CodeGenCXX/no-exceptions.cpp diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index a992b459d8..85db6bb973 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -317,6 +317,9 @@ void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) { } void CodeGenFunction::EmitStartEHSpec(const Decl *D) { + if (!Exceptions) + return; + const FunctionDecl* FD = dyn_cast_or_null(D); if (FD == 0) return; @@ -411,6 +414,9 @@ void CodeGenFunction::EmitStartEHSpec(const Decl *D) { } void CodeGenFunction::EmitEndEHSpec(const Decl *D) { + if (!Exceptions) + return; + const FunctionDecl* FD = dyn_cast_or_null(D); if (FD == 0) return; diff --git a/test/CodeGenCXX/no-exceptions.cpp b/test/CodeGenCXX/no-exceptions.cpp new file mode 100644 index 0000000000..da672c43f8 --- /dev/null +++ b/test/CodeGenCXX/no-exceptions.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s + +void g(); + +// CHECK: define void @_Z1fv() nounwind +void f() throw (int) { + + // CHECK-NOT: invoke void @_Z1gv + g(); + // CHECK: call void @_Z1gv() + // CHECK: ret void +} -- 2.40.0