1// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -Wno-objc-root-class -fexceptions -fobjc-exceptions -o %t %s
2// RUN: FileCheck -check-prefix=CHECK-X86_64 < %t %s
3// RUN: FileCheck -check-prefix=CHECK-EHTYPE < %t %s
4// rdar://16462586
5
6// We need exactly 3 of these.
7// CHECK-EHTYPE: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
8// CHECK-EHTYPE: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
9// CHECK-EHTYPE: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
10// CHECK-EHTYPE-NOT: @"OBJC_EHTYPE_$_MySecretNamespace.EH3"
11
12// CHECK-X86_64: @"OBJC_CLASS_$_MySecretNamespace.A" ={{.*}} global {{.*}}, section "__DATA, __objc_data", align 8
13// CHECK-X86_64: @"OBJC_METACLASS_$_MySecretNamespace.A" ={{.*}} global {{.*}}, section "__DATA, __objc_data", align 8
14// CHECK-X86_64: @OBJC_CLASS_NAME_ = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
15// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak{{.*}} global {{.*}}, align 8
16// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
17// CHECK-X86_64: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" ={{.*}} global {{.*}}, section "__DATA,__objc_const", align 8
18// CHECK-X86_64: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 8
19// CHECK-X86_64: define internal void @"\01-[A im0]"
20// CHECK-X86_64: define internal void @"\01-[A(Cat) im1]"
21
22// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -fobjc-exceptions -fvisibility hidden -emit-llvm -o %t %s
23// RUN: FileCheck -check-prefix=CHECK-X86_64-HIDDEN < %t %s
24
25// CHECK-X86_64-HIDDEN: @"OBJC_CLASS_$_MySecretNamespace.A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
26// CHECK-X86_64-HIDDEN: @"OBJC_METACLASS_$_MySecretNamespace.A" = hidden global {{.*}}, section "__DATA, __objc_data", align 8
27// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak hidden global
28// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
29// CHECK-X86_64-HIDDEN: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" = hidden global {{.*}}, section "__DATA,__objc_const", align 8
30// CHECK-X86_64-HIDDEN: define internal void @"\01-[A im0]"
31// CHECK-X86_64-HIDDEN: define internal void @"\01-[A(Cat) im1]"
32
33// RUN: %clang_cc1 -triple armv6-apple-darwin10 -target-abi apcs-gnu -Wno-objc-root-class -fobjc-exceptions -emit-llvm -o %t %s
34// RUN: FileCheck -check-prefix=CHECK-ARMV6 < %t %s
35
36// CHECK-ARMV6: @"OBJC_CLASS_$_MySecretNamespace.A" ={{.*}} global {{.*}}, section "__DATA, __objc_data", align 4
37// CHECK-ARMV6: @"OBJC_METACLASS_$_MySecretNamespace.A" ={{.*}} global {{.*}}, section "__DATA, __objc_data", align 4
38// CHECK-ARMV6: @OBJC_CLASS_NAME_ = {{.*}}, section "__TEXT,__objc_classname,cstring_literals", align 1
39// CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH1" = weak{{.*}} global {{.*}}, align 4
40// CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH2" = external global
41// CHECK-ARMV6: @"OBJC_EHTYPE_$_MySecretNamespace.EH3" ={{.*}} global {{.*}}, section "__DATA,__objc_const", align 4
42// CHECK-ARMV6: @"OBJC_LABEL_CLASS_$" = private global {{.*}}, section "__DATA,__objc_classlist,regular,no_dead_strip", align 4
43// CHECK-ARMV6: define internal void @"\01-[A im0]"
44// CHECK-ARMV6: define internal void @"\01-[A(Cat) im1]"
45
46__attribute__((objc_runtime_name("MySecretNamespace.A")))
47@interface A
48@end
49
50@implementation A
51-(void) im0 {
52}
53@end
54
55@implementation A (Cat)
56-(void) im1 {
57}
58@end
59
60__attribute__((objc_runtime_name("MySecretNamespace.EH1")))
61@interface EH1
62@end
63
64__attribute__((objc_runtime_name("MySecretNamespace.EH2")))
65__attribute__((__objc_exception__))
66@interface EH2
67@end
68
69__attribute__((objc_runtime_name("MySecretNamespace.EH3")))
70__attribute__((__objc_exception__))
71@interface EH3
72@end
73
74void f1();
75
76void f0(id x) {
77  @try {
78    f1();
79  } @catch (EH1 *x) {
80  } @catch (EH2 *x) {
81  } @catch (EH3 *x) {
82  }
83}
84
85@implementation EH3
86@end
87