]> granicus.if.org Git - clang/commitdiff
Make EmitStartEHSpec and EmitEndEHSpec return early when exceptions are disabled.
authorAnders Carlsson <andersca@mac.com>
Sat, 6 Feb 2010 23:59:05 +0000 (23:59 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 6 Feb 2010 23:59:05 +0000 (23:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95509 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGException.cpp
test/CodeGenCXX/no-exceptions.cpp [new file with mode: 0644]

index a992b459d868b04907f3adae5dedf54202e327d9..85db6bb973a761b6469f45d06f6cf817827a63af 100644 (file)
@@ -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<FunctionDecl>(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<FunctionDecl>(D);
   if (FD == 0)
     return;
diff --git a/test/CodeGenCXX/no-exceptions.cpp b/test/CodeGenCXX/no-exceptions.cpp
new file mode 100644 (file)
index 0000000..da672c4
--- /dev/null
@@ -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
+}