Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Index / Core / external-source-symbol-attr.m
blob1f907912737b0d7742124775ca10ba31b8d7f44a
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
10 @class I1;
11 @class I2;
13 // This should not be indexed.
14 GEN_DECL("some_module")
15 @interface I1
16 // CHECK-NOT: [[@LINE-1]]:12 |
17 -(void)method;
18 // CHECK-NOT: [[@LINE-1]]:8 |
19 @end
21 EXT_DECL("some_module")
22 @interface I2
23 // CHECK: [[@LINE-1]]:12 | class/Swift | I2 | c:@M@some_module@objc(cs)I2 | {{.*}} | Decl | rel: 0
24 -(void)method;
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
26 @property int prop;
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 |
30 @end
32 void test1(I1 *o) {
33 // CHECK: [[@LINE-1]]:12 | class/Swift | I1 | c:@M@some_module@objc(cs)I1 |
34   [o method];
35   // CHECK: [[@LINE-1]]:6 | instance-method/Swift | method | c:@M@some_module@objc(cs)I1(im)method |
38 EXT_DECL("some_module")
39 @protocol ExtProt
40 // CHECK: [[@LINE-1]]:11 | protocol/Swift | ExtProt | c:@M@some_module@objc(pl)ExtProt |
41 @end
43 @interface I1(cat)
44 // CHECK: [[@LINE-1]]:15 | extension/ObjC | cat | c:@M@some_module@objc(cy)I1@cat |
45 -(void)cat_method;
46 // CHECK: [[@LINE-1]]:8 | instance-method/ObjC | cat_method | c:@M@some_module@objc(cs)I1(im)cat_method
47 @end
49 EXT_DECL("cat_module")
50 @interface I1(cat2)
51 // CHECK: [[@LINE-1]]:15 | extension/Swift | cat2 | c:@CM@cat_module@some_module@objc(cy)I1@cat2 |
52 -(void)cat_method2;
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 |
58 @end
60 #define NS_ENUM(_name, _type) enum _name:_type _name; enum _name : _type
62 #pragma clang attribute PUSH_GEN_DECL("modname")
64 @interface I3
65 // CHECK-NOT: [[@LINE-1]]:12 |
66 -(void)meth;
67 // CHECK-NOT: [[@LINE-1]]:8 |
68 @end
70 @interface I3(cat)
71 // CHECK-NOT: [[@LINE-1]]:12 |
72 // CHECK-NOT: [[@LINE-2]]:15 |
73 -(void)meth2;
74 // CHECK-NOT: [[@LINE-1]]:8 |
75 @end
77 @protocol ExtProt2
78 // CHECK-NOT: [[@LINE-1]]:11 |
79 -(void)meth;
80 // CHECK-NOT: [[@LINE-1]]:8 |
81 @end
83 typedef NS_ENUM(SomeEnum, int) {
84 // CHECK-NOT: [[@LINE-1]]:17 |
85   SomeEnumFirst = 0,
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 |
95   [i3 meth];
96   // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth | c:@M@modname@objc(cs)I3(im)meth |
97   [i3 meth2];
98   // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth2 | c:@CM@modname@objc(cs)I3(im)meth2 |
99   [prot2 meth];
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;
108 @end
109 #pragma clang attribute pop
111 void test3(I3 *i3) {
112   [i3 meth_other_mod];
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");
118 void test4() {
119   function();
120   // CHECK: [[@LINE-1]]:3 | function/Swift | function | s:8SwiftMod8functionyyF