1 // RUN: c-index-test core -print-source-symbols -- %s -target x86_64-apple-macosx10.7 | FileCheck %s
3 #define EXT_DECL(mod_name) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name)))
4 #define GEN_DECL(mod_name) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name, generated_declaration)))
5 #define PUSH_GEN_DECL(mod_name) push(GEN_DECL(mod_name), apply_to=any(enum, objc_interface, objc_category, objc_protocol))
7 #define GEN_DECL_USR(mod_name, usr) __attribute__((external_source_symbol(language="Swift", defined_in=mod_name, USR=usr, generated_declaration)))
9 // Forward declarations should not affect module namespacing below
13 // This should not be indexed.
14 GEN_DECL("some_module")
16 // CHECK-NOT: [[@LINE-1]]:12 |
18 // CHECK-NOT: [[@LINE-1]]:8 |
21 EXT_DECL("some_module")
23 // CHECK: [[@LINE-1]]:12 | class/Swift | I2 | c:@M@some_module@objc(cs)I2 | {{.*}} | Decl | rel: 0
25 // 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 // CHECK: [[@LINE-1]]:15 | instance-method/acc-get/Swift | prop | c:@M@some_module@objc(cs)I2(im)prop |
28 // CHECK: [[@LINE-2]]:15 | instance-method/acc-set/Swift | setProp: | c:@M@some_module@objc(cs)I2(im)setProp: |
29 // CHECK: [[@LINE-3]]:15 | instance-property/Swift | prop | c:@M@some_module@objc(cs)I2(py)prop |
33 // CHECK: [[@LINE-1]]:12 | class/Swift | I1 | c:@M@some_module@objc(cs)I1 |
35 // CHECK: [[@LINE-1]]:6 | instance-method/Swift | method | c:@M@some_module@objc(cs)I1(im)method |
38 EXT_DECL("some_module")
40 // CHECK: [[@LINE-1]]:11 | protocol/Swift | ExtProt | c:@M@some_module@objc(pl)ExtProt |
44 // CHECK: [[@LINE-1]]:15 | extension/ObjC | cat | c:@M@some_module@objc(cy)I1@cat |
46 // CHECK: [[@LINE-1]]:8 | instance-method/ObjC | cat_method | c:@M@some_module@objc(cs)I1(im)cat_method
49 EXT_DECL("cat_module")
51 // CHECK: [[@LINE-1]]:15 | extension/Swift | cat2 | c:@CM@cat_module@some_module@objc(cy)I1@cat2 |
53 // CHECK: [[@LINE-1]]:8 | instance-method/Swift | cat_method2 | c:@CM@cat_module@some_module@objc(cs)I1(im)cat_method2
54 @property int cat_prop2;
55 // CHECK: [[@LINE-1]]:15 | instance-method/acc-get/Swift | cat_prop2 | c:@CM@cat_module@some_module@objc(cs)I1(im)cat_prop2 |
56 // CHECK: [[@LINE-2]]:15 | instance-method/acc-set/Swift | setCat_prop2: | c:@CM@cat_module@some_module@objc(cs)I1(im)setCat_prop2: |
57 // CHECK: [[@LINE-3]]:15 | instance-property/Swift | cat_prop2 | c:@CM@cat_module@some_module@objc(cs)I1(py)cat_prop2 |
60 #define NS_ENUM(_name, _type) enum _name:_type _name; enum _name : _type
62 #pragma clang attribute PUSH_GEN_DECL("modname")
65 // CHECK-NOT: [[@LINE-1]]:12 |
67 // CHECK-NOT: [[@LINE-1]]:8 |
71 // CHECK-NOT: [[@LINE-1]]:12 |
72 // CHECK-NOT: [[@LINE-2]]:15 |
74 // CHECK-NOT: [[@LINE-1]]:8 |
78 // CHECK-NOT: [[@LINE-1]]:11 |
80 // CHECK-NOT: [[@LINE-1]]:8 |
83 typedef NS_ENUM(SomeEnum, int) {
84 // CHECK-NOT: [[@LINE-1]]:17 |
86 // CHECK-NOT: [[@LINE-1]]:3 |
89 #pragma clang attribute pop
91 void test2(I3 *i3, id<ExtProt2> prot2, SomeEnum some) {
92 // CHECK: [[@LINE-1]]:12 | class/Swift | I3 | c:@M@modname@objc(cs)I3 |
93 // CHECK: [[@LINE-2]]:23 | protocol/Swift | ExtProt2 | c:@M@modname@objc(pl)ExtProt2 |
94 // CHECK: [[@LINE-3]]:40 | enum/Swift | SomeEnum | c:@M@modname@E@SomeEnum |
96 // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth | c:@M@modname@objc(cs)I3(im)meth |
98 // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth2 | c:@CM@modname@objc(cs)I3(im)meth2 |
100 // CHECK: [[@LINE-1]]:10 | instance-method(protocol)/Swift | meth | c:@M@modname@objc(pl)ExtProt2(im)meth |
101 some = SomeEnumFirst;
102 // CHECK: [[@LINE-1]]:10 | enumerator/Swift | SomeEnumFirst | c:@M@modname@E@SomeEnum@SomeEnumFirst |
105 #pragma clang attribute PUSH_GEN_DECL("other_mod_for_cat")
106 @interface I3(cat_other_mod)
107 -(void)meth_other_mod;
109 #pragma clang attribute pop
113 // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth_other_mod | c:@CM@other_mod_for_cat@modname@objc(cs)I3(im)meth_other_mod |
116 void function() GEN_DECL_USR("SwiftMod", "s:8SwiftMod8functionyyF");
120 // CHECK: [[@LINE-1]]:3 | function/Swift | function | s:8SwiftMod8functionyyF