]> granicus.if.org Git - clang/commitdiff
When creating functions to run global initializers and destructors, mark them
authorJohn McCall <rjmccall@apple.com>
Tue, 6 Jul 2010 04:38:10 +0000 (04:38 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 6 Jul 2010 04:38:10 +0000 (04:38 +0000)
as nounwind in -fno-exceptions.  Fixes rdar://problem/8090834.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107639 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDeclCXX.cpp
test/CodeGenCXX/global-init.cpp

index d7d01847ea427433cdbe2e3d9e3fe7282a61d904..ec3f38667b7ad4812d81f64fe5c18a90b4d5bd36 100644 (file)
@@ -152,6 +152,9 @@ CreateGlobalInitOrDestructFunction(CodeGenModule &CGM,
         CGM.getContext().Target.getStaticInitSectionSpecifier())
     Fn->setSection(Section);
 
+  if (!CGM.getLangOptions().Exceptions)
+    Fn->setDoesNotThrow();
+
   return Fn;
 }
 
index 80a7a7a62af0041a6481060bf6fecb675f1ff874..8ee087e29d11fcd6d93e1ba4c859cf373e4cfa51 100644 (file)
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -fexceptions %s -o - |FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck -check-prefix NOEXC %s
 
 struct A {
   A();
@@ -30,3 +31,5 @@ D d;
 
 // CHECK: define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" {
 
+// rdar://problem/8090834: this should be nounwind
+// CHECK-NOEXC: define internal void @_GLOBAL__I_a() nounwind section "__TEXT,__StaticInit,regular,pure_instructions" {