Make clang -cc1 disable Objective-C exceptions by default, and add a -fobjc-exceptions flag to turn them on.

Update all tests accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126177 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2011-02-22 01:52:06 +00:00
parent 95bba6f26f
commit e9b801f763
32 changed files with 48 additions and 48 deletions

View File

@ -420,7 +420,7 @@ def fexceptions : Flag<"-fexceptions">,
HelpText<"Enable support for exception handling">; HelpText<"Enable support for exception handling">;
def fsjlj_exceptions : Flag<"-fsjlj-exceptions">, def fsjlj_exceptions : Flag<"-fsjlj-exceptions">,
HelpText<"Use SjLj style exceptions">; HelpText<"Use SjLj style exceptions">;
def fno_objc_exceptions : Flag<"-fno-objc-exceptions">, def fobjc_exceptions : Flag<"-fobjc-exceptions">,
HelpText<"Disable Objective-C exceptions">; HelpText<"Disable Objective-C exceptions">;
def ffreestanding : Flag<"-ffreestanding">, def ffreestanding : Flag<"-ffreestanding">,
HelpText<"Assert that the compilation takes place in a freestanding environment">; HelpText<"Assert that the compilation takes place in a freestanding environment">;

View File

@ -1546,10 +1546,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-fobjc-default-synthesize-properties"); CmdArgs.push_back("-fobjc-default-synthesize-properties");
} }
// -fobjc-exceptions is default. // -fno-objc-exceptions is default.
if (!Args.hasFlag(options::OPT_fobjc_exceptions, if (IsRewriter || Args.hasFlag(options::OPT_fobjc_exceptions,
options::OPT_fno_objc_exceptions)) options::OPT_fno_objc_exceptions))
CmdArgs.push_back("-fno-objc-exceptions"); CmdArgs.push_back("-fobjc-exceptions");
} }
if (!Args.hasFlag(options::OPT_fassume_sane_operator_new, if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,

View File

@ -1460,7 +1460,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
if (Args.hasArg(OPT_fno_threadsafe_statics)) if (Args.hasArg(OPT_fno_threadsafe_statics))
Opts.ThreadsafeStatics = 0; Opts.ThreadsafeStatics = 0;
Opts.Exceptions = Args.hasArg(OPT_fexceptions); Opts.Exceptions = Args.hasArg(OPT_fexceptions);
Opts.ObjCExceptions = !Args.hasArg(OPT_fno_objc_exceptions); Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
Opts.RTTI = !Args.hasArg(OPT_fno_rtti); Opts.RTTI = !Args.hasArg(OPT_fno_rtti);
Opts.Blocks = Args.hasArg(OPT_fblocks); Opts.Blocks = Args.hasArg(OPT_fblocks);
Opts.CharIsSigned = !Args.hasArg(OPT_fno_signed_char); Opts.CharIsSigned = !Args.hasArg(OPT_fno_signed_char);
@ -1490,7 +1490,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls); Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags); Opts.PICLevel = Args.getLastArgIntValue(OPT_pic_level, 0, Diags);
Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions); Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
Opts.ObjCExceptions = !Args.hasArg(OPT_fno_objc_exceptions); Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
Opts.Static = Args.hasArg(OPT_static_define); Opts.Static = Args.hasArg(OPT_static_define);
Opts.DumpRecordLayouts = Args.hasArg(OPT_fdump_record_layouts); Opts.DumpRecordLayouts = Args.hasArg(OPT_fdump_record_layouts);
Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts); Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts);

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -fblocks -o %t %s // RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -fobjc-exceptions -fblocks -o %t %s
// rdar://7590273 // rdar://7590273
void EXIT(id e); void EXIT(id e);

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-nonfragile-abi -fexceptions -O2 -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-nonfragile-abi -fexceptions -fobjc-exceptions -O2 -o - %s | FileCheck %s
// rdar://problem/8535238 // rdar://problem/8535238
// CHECK: declare void @objc_exception_rethrow() // CHECK: declare void @objc_exception_rethrow()

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -O2 -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -fobjc-exceptions -O2 -o - %s | FileCheck %s
// //
// <rdar://problem/7471679> [irgen] [eh] Exception code built with clang (x86_64) crashes // <rdar://problem/7471679> [irgen] [eh] Exception code built with clang (x86_64) crashes

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fgnu-runtime -o - %s | FileCheck %s // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fgnu-runtime -o - %s | FileCheck %s
void opaque(void); void opaque(void);
void log(int i); void log(int i);

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -fexceptions -o %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -fexceptions -fobjc-exceptions -o %t %s
// RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s // RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s
// RUN: grep '@"OBJC_EHTYPE_$_EH3"' %t | count 3 // RUN: grep '@"OBJC_EHTYPE_$_EH3"' %t | count 3
@ -12,7 +12,7 @@
// CHECK-X86_64: define internal void @"\01-[A im0]" // CHECK-X86_64: define internal void @"\01-[A im0]"
// CHECK-X86_64: define internal void @"\01-[A(Cat) im1]" // CHECK-X86_64: define internal void @"\01-[A(Cat) im1]"
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fvisibility hidden -emit-llvm -o %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s
// RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s // RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s
// CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8 // CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
@ -23,7 +23,7 @@
// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]" // CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
// CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]" // CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]"
// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-nonfragile-abi -emit-llvm -o %t %s // RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -fobjc-nonfragile-abi -fobjc-exceptions -emit-llvm -o %t %s
// RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s // RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s
// CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4 // CHECK-ARMV6: @"OBJC_CLASS_$_A" = global {{.*}}, section "__DATA, __objc_data", align 4

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck %s // RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -fobjc-exceptions %s -o - | FileCheck %s
extern int printf(const char*, ...); extern int printf(const char*, ...);

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm %s -o - // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -fobjc-exceptions %s -o -
void f0(id x) { void f0(id x) {
@synchronized (x) { @synchronized (x) {

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 %s -S -o - -triple=i686-apple-darwin9 // RUN: %clang_cc1 %s -fobjc-exceptions -S -o - -triple=i686-apple-darwin9
// RUN: %clang_cc1 %s -S -o - -triple=x86_64-apple-darwin9 // RUN: %clang_cc1 %s -fobjc-exceptions -S -o - -triple=x86_64-apple-darwin9
// rdar://6757213 - Don't crash if the internal proto for // rdar://6757213 - Don't crash if the internal proto for
// __objc_personality_v0 mismatches with an actual one. // __objc_personality_v0 mismatches with an actual one.

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -fexceptions -o - %s | FileCheck --check-prefix=DEFAULT_EH %s // RUN: %clang_cc1 -fobjc-nonfragile-abi -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck --check-prefix=DEFAULT_EH %s
// RUN: %clang_cc1 -fsjlj-exceptions -fobjc-nonfragile-abi -fexceptions -emit-llvm -o - %s | FileCheck --check-prefix=SJLJ_EH %s // RUN: %clang_cc1 -fsjlj-exceptions -fobjc-nonfragile-abi -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck --check-prefix=SJLJ_EH %s
// DEFAULT_EH: declare void @_Unwind_Resume_or_Rethrow(i8*) // DEFAULT_EH: declare void @_Unwind_Resume_or_Rethrow(i8*)
// SJLJ_EH: declare void @_Unwind_SjLj_Resume_or_Rethrow(i8*) // SJLJ_EH: declare void @_Unwind_SjLj_Resume_or_Rethrow(i8*)

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only %s // RUN: %clang_cc1 -fsyntax-only -fobjc-exceptions %s
// RUN: %clang_cc1 -ast-print %s // RUN: %clang_cc1 -ast-print -fobjc-exceptions %s
// RUN: %clang_cc1 -ast-dump %s // RUN: %clang_cc1 -ast-dump -fobjc-exceptions %s
#include "objc-language-features.inc" #include "objc-language-features.inc"

View File

@ -1,3 +1,3 @@
// RUN: %clang_cc1 -triple i386-unknown-unknown -fgnu-runtime -emit-llvm -o %t %s // RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-exceptions -fgnu-runtime -emit-llvm -o %t %s
#include "objc-language-features.inc" #include "objc-language-features.inc"

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -emit-llvm -o %t %s // RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -o %t %s
// RUN: %clang_cc1 -g -emit-llvm -o %t %s // RUN: %clang_cc1 -g -emit-llvm -fobjc-exceptions -o %t %s
#include "objc-language-features.inc" #include "objc-language-features.inc"

View File

@ -3,7 +3,7 @@
// TEST0: clang{{.*}}" "-cc1" // TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc" // TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
// TEST0: "-fmessage-length" "0" "-fdiagnostics-show-option" // TEST0: "-fmessage-length" "0" "-fobjc-exceptions" "-fdiagnostics-show-option"
// TEST0: rewrite-objc.m" // TEST0: rewrite-objc.m"
// RUN: not %clang -ccc-no-clang -ccc-host-triple unknown -rewrite-objc %s -o - -### 2>&1 | \ // RUN: not %clang -ccc-no-clang -ccc-host-triple unknown -rewrite-objc %s -o - -### 2>&1 | \

View File

@ -1,11 +1,11 @@
// Test this without pch. // Test this without pch.
// RUN: %clang_cc1 -include %S/objc_stmts.h -emit-llvm -o - %s // RUN: %clang_cc1 -include %S/objc_stmts.h -emit-llvm -fobjc-exceptions -o - %s
// RUN: %clang_cc1 -include %S/objc_stmts.h -ast-dump -o - %s 2>&1 | FileCheck %s // RUN: %clang_cc1 -include %S/objc_stmts.h -ast-dump -fobjc-exceptions -o - %s 2>&1 | FileCheck %s
// Test with pch. // Test with pch.
// RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_stmts.h // RUN: %clang_cc1 -x objective-c -emit-pch -fobjc-exceptions -o %t %S/objc_stmts.h
// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s // RUN: %clang_cc1 -include-pch %t -emit-llvm -fobjc-exceptions -o - %s
// RUN: %clang_cc1 -include-pch %t -ast-dump -o - %s 2>&1 | FileCheck %s // RUN: %clang_cc1 -include-pch %t -ast-dump -fobjc-exceptions -o - %s 2>&1 | FileCheck %s
// CHECK: catch parm = "A *a" // CHECK: catch parm = "A *a"
// CHECK: catch parm = "B *b" // CHECK: catch parm = "B *b"

View File

@ -1,5 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
// RUN: %clang_cc1 -fsyntax-only -verify -x objective-c++ %s // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -x objective-c++ %s
void * proc(); void * proc();
@interface NSConstantString @interface NSConstantString

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -rewrite-objc -verify %s -o - // RUN: %clang_cc1 -rewrite-objc -fobjc-exceptions -verify %s -o -
int main() { int main() {
@try { @try {

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -rewrite-objc -o - %s // RUN: %clang_cc1 -rewrite-objc -fobjc-exceptions -o - %s
// rdar://7522880 // rdar://7522880
@interface NSException @interface NSException

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -rewrite-objc %s -o - // RUN: %clang_cc1 -rewrite-objc -fobjc-exceptions %s -o -
@interface Foo @end @interface Foo @end
@interface GARF @end @interface GARF @end

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -verify %s // RUN: %clang_cc1 -verify -fobjc-exceptions %s
@interface A @end @interface A @end
@protocol P; @protocol P;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify // RUN: %clang_cc1 %s -fsyntax-only -verify -fobjc-exceptions
// rdar://6124613 // rdar://6124613
void test1() { void test1() {

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fno-objc-exceptions -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify %s
void f() { void f() {
@throw @"Hello"; // expected-error {{cannot use '@throw' with Objective-C exceptions disabled}} @throw @"Hello"; // expected-error {{cannot use '@throw' with Objective-C exceptions disabled}}

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
# 1 "<command line>" # 1 "<command line>"
# 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3 # 1 "/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h" 1 3
typedef signed char BOOL; typedef signed char BOOL;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only %s -verify // RUN: %clang_cc1 -fsyntax-only %s -verify -fobjc-exceptions
// Test case for: // Test case for:
// <rdar://problem/6248119> @finally doesn't introduce a new scope // <rdar://problem/6248119> @finally doesn't introduce a new scope

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 %s -fsyntax-only -verify -Wmissing-noreturn // RUN: %clang_cc1 %s -fsyntax-only -verify -Wmissing-noreturn -fobjc-exceptions
int test1() { int test1() {
id a; id a;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
@class A, B, C; @class A, B, C;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 %s -verify -fsyntax-only // RUN: %clang_cc1 %s -verify -fsyntax-only -fobjc-exceptions
struct some_struct; struct some_struct;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
typedef signed char BOOL; typedef signed char BOOL;
typedef struct _NSZone NSZone; typedef struct _NSZone NSZone;

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-exception-parameter %s // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wunused-exception-parameter %s
void f0() { void f0() {
@try {} @catch(id a) {} // expected-warning{{unused exception parameter 'a'}} @try {} @catch(id a) {} // expected-warning{{unused exception parameter 'a'}}
} }

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions %s
@interface NSException @interface NSException
@end @end