Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Index / Core / external-source-symbol-attr.m
blobfee80d3b0fdf6ca525a18c6e9e5a4d844c1c5a69
1 // XFAIL: target={{.*}}-aix{{.*}}
2 // RUN: c-index-test core -print-source-symbols -- %s -target x86_64-apple-macosx10.7 | FileCheck %s
4 #define EXT_DECL(mod_name) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name)))
5 #define GEN_DECL(mod_name) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name, generated_declaration)))
6 #define PUSH_GEN_DECL(mod_name) push(GEN_DECL(mod_name), apply_to=any(enum, objc_interface, objc_category, objc_protocol))
8 #define GEN_DECL_USR(mod_name, usr) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name, USR=usr, generated_declaration)))
10 // Forward declarations should not affect module namespacing below
11 @class I1;
12 @class I2;
14 // This should not be indexed.
15 GEN_DECL("some_module")
16 @interface I1
17 // CHECK-NOT: [[@LINE-1]]:12 |
18 -(void)method;
19 // CHECK-NOT: [[@LINE-1]]:8 |
20 @end
22 EXT_DECL("some_module")
23 @interface I2
24 // CHECK: [[@LINE-1]]:12 | class/Swift | I2 | c:@M@some_module@objc(cs)I2 | {{.*}} | Decl | rel: 0
25 -(void)method;
26 // CHECK: [[@LINE-1]]:8 | instance-method/Swift | method | c:@M@some_module@objc(cs)I2(im)method | -[I2 method] | Decl,Dyn,RelChild | rel: 1
27 @property int prop;
28 // CHECK: [[@LINE-1]]:15 | instance-method/acc-get/Swift | prop | c:@M@some_module@objc(cs)I2(im)prop |
29 // CHECK: [[@LINE-2]]:15 | instance-method/acc-set/Swift | setProp: | c:@M@some_module@objc(cs)I2(im)setProp: |
30 // CHECK: [[@LINE-3]]:15 | instance-property/Swift | prop | c:@M@some_module@objc(cs)I2(py)prop |
31 @end
33 void test1(I1 *o) {
34 // CHECK: [[@LINE-1]]:12 | class/Swift | I1 | c:@M@some_module@objc(cs)I1 |
35   [o method];
36   // CHECK: [[@LINE-1]]:6 | instance-method/Swift | method | c:@M@some_module@objc(cs)I1(im)method |
39 EXT_DECL("some_module")
40 @protocol ExtProt
41 // CHECK: [[@LINE-1]]:11 | protocol/Swift | ExtProt | c:@M@some_module@objc(pl)ExtProt |
42 @end
44 @interface I1(cat)
45 // CHECK: [[@LINE-1]]:15 | extension/ObjC | cat | c:@M@some_module@objc(cy)I1@cat |
46 -(void)cat_method;
47 // CHECK: [[@LINE-1]]:8 | instance-method/ObjC | cat_method | c:@M@some_module@objc(cs)I1(im)cat_method
48 @end
50 EXT_DECL("cat_module")
51 @interface I1(cat2)
52 // CHECK: [[@LINE-1]]:15 | extension/Swift | cat2 | c:@CM@cat_module@some_module@objc(cy)I1@cat2 |
53 -(void)cat_method2;
54 // CHECK: [[@LINE-1]]:8 | instance-method/Swift | cat_method2 | c:@CM@cat_module@some_module@objc(cs)I1(im)cat_method2
55 @property int cat_prop2;
56 // CHECK: [[@LINE-1]]:15 | instance-method/acc-get/Swift | cat_prop2 | c:@CM@cat_module@some_module@objc(cs)I1(im)cat_prop2 |
57 // CHECK: [[@LINE-2]]:15 | instance-method/acc-set/Swift | setCat_prop2: | c:@CM@cat_module@some_module@objc(cs)I1(im)setCat_prop2: |
58 // CHECK: [[@LINE-3]]:15 | instance-property/Swift | cat_prop2 | c:@CM@cat_module@some_module@objc(cs)I1(py)cat_prop2 |
59 @end
61 #define NS_ENUM(_name, _type) enum _name:_type _name; enum _name : _type
63 #pragma clang attribute PUSH_GEN_DECL("modname")
65 @interface I3
66 // CHECK-NOT: [[@LINE-1]]:12 |
67 -(void)meth;
68 // CHECK-NOT: [[@LINE-1]]:8 |
69 @end
71 @interface I3(cat)
72 // CHECK-NOT: [[@LINE-1]]:12 |
73 // CHECK-NOT: [[@LINE-2]]:15 |
74 -(void)meth2;
75 // CHECK-NOT: [[@LINE-1]]:8 |
76 @end
78 @protocol ExtProt2
79 // CHECK-NOT: [[@LINE-1]]:11 |
80 -(void)meth;
81 // CHECK-NOT: [[@LINE-1]]:8 |
82 @end
84 typedef NS_ENUM(SomeEnum, int) {
85 // CHECK-NOT: [[@LINE-1]]:17 |
86   SomeEnumFirst = 0,
87   // CHECK-NOT: [[@LINE-1]]:3 |
90 #pragma clang attribute pop
92 void test2(I3 *i3, id<ExtProt2> prot2, SomeEnum some) {
93   // CHECK: [[@LINE-1]]:12 | class/Swift | I3 | c:@M@modname@objc(cs)I3 |
94   // CHECK: [[@LINE-2]]:23 | protocol/Swift | ExtProt2 | c:@M@modname@objc(pl)ExtProt2 |
95   // CHECK: [[@LINE-3]]:40 | enum/Swift | SomeEnum | c:@M@modname@E@SomeEnum |
96   [i3 meth];
97   // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth | c:@M@modname@objc(cs)I3(im)meth |
98   [i3 meth2];
99   // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth2 | c:@CM@modname@objc(cs)I3(im)meth2 |
100   [prot2 meth];
101   // CHECK: [[@LINE-1]]:10 | instance-method(protocol)/Swift | meth | c:@M@modname@objc(pl)ExtProt2(im)meth |
102   some = SomeEnumFirst;
103   // CHECK: [[@LINE-1]]:10 | enumerator/Swift | SomeEnumFirst | c:@M@modname@E@SomeEnum@SomeEnumFirst |
106 #pragma clang attribute PUSH_GEN_DECL("other_mod_for_cat")
107 @interface I3(cat_other_mod)
108 -(void)meth_other_mod;
109 @end
110 #pragma clang attribute pop
112 void test3(I3 *i3) {
113   [i3 meth_other_mod];
114   // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth_other_mod | c:@CM@other_mod_for_cat@modname@objc(cs)I3(im)meth_other_mod |
117 void function() GEN_DECL_USR("SwiftMod", "s:8SwiftMod8functionyyF");
119 void test4() {
120   function();
121   // CHECK: [[@LINE-1]]:3 | function/Swift | function | s:8SwiftMod8functionyyF