Clang Project

clang_source_code/test/Index/Core/external-source-symbol-attr.m
1// RUN: c-index-test core -print-source-symbols -- %s -target x86_64-apple-macosx10.7 | FileCheck %s
2
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))
6
7// Forward declarations should not affect module namespacing below
8@class I1;
9@class I2;
10
11// This should not be indexed.
12GEN_DECL("some_module")
13@interface I1
14// CHECK-NOT: [[@LINE-1]]:12 |
15-(void)method;
16// CHECK-NOT: [[@LINE-1]]:8 |
17@end
18
19EXT_DECL("some_module")
20@interface I2
21// CHECK: [[@LINE-1]]:12 | class/Swift | I2 | c:@M@some_module@objc(cs)I2 | {{.*}} | Decl | rel: 0
22-(void)method;
23// CHECK: [[@LINE-1]]:8 | instance-method/Swift | method | c:@M@some_module@objc(cs)I2(im)method | -[I2 method] | Decl,Dyn,RelChild | rel: 1
24@end
25
26void test1(I1 *o) {
27// CHECK: [[@LINE-1]]:12 | class/Swift | I1 | c:@M@some_module@objc(cs)I1 |
28  [o method];
29  // CHECK: [[@LINE-1]]:6 | instance-method/Swift | method | c:@M@some_module@objc(cs)I1(im)method |
30}
31
32EXT_DECL("some_module")
33@protocol ExtProt
34// CHECK: [[@LINE-1]]:11 | protocol/Swift | ExtProt | c:@M@some_module@objc(pl)ExtProt |
35@end
36
37@interface I1(cat)
38// CHECK: [[@LINE-1]]:15 | extension/ObjC | cat | c:@M@some_module@objc(cy)I1@cat |
39-(void)cat_method;
40// CHECK: [[@LINE-1]]:8 | instance-method/ObjC | cat_method | c:@M@some_module@objc(cs)I1(im)cat_method
41@end
42
43EXT_DECL("cat_module")
44@interface I1(cat2)
45// CHECK: [[@LINE-1]]:15 | extension/Swift | cat2 | c:@CM@cat_module@some_module@objc(cy)I1@cat2 |
46-(void)cat_method2;
47// CHECK: [[@LINE-1]]:8 | instance-method/Swift | cat_method2 | c:@CM@cat_module@some_module@objc(cs)I1(im)cat_method2
48@end
49
50#define NS_ENUM(_name, _type) enum _name:_type _name; enum _name : _type
51
52#pragma clang attribute PUSH_GEN_DECL("modname")
53
54@interface I3
55// CHECK-NOT: [[@LINE-1]]:12 |
56-(void)meth;
57// CHECK-NOT: [[@LINE-1]]:8 |
58@end
59
60@interface I3(cat)
61// CHECK-NOT: [[@LINE-1]]:12 |
62// CHECK-NOT: [[@LINE-2]]:15 |
63-(void)meth2;
64// CHECK-NOT: [[@LINE-1]]:8 |
65@end
66
67@protocol ExtProt2
68// CHECK-NOT: [[@LINE-1]]:11 |
69-(void)meth;
70// CHECK-NOT: [[@LINE-1]]:8 |
71@end
72
73typedef NS_ENUM(SomeEnum, int) {
74// CHECK-NOT: [[@LINE-1]]:17 |
75  SomeEnumFirst = 0,
76  // CHECK-NOT: [[@LINE-1]]:3 |
77};
78
79#pragma clang attribute pop
80
81void test2(I3 *i3, id<ExtProt2> prot2, SomeEnum some) {
82  // CHECK: [[@LINE-1]]:12 | class/Swift | I3 | c:@M@modname@objc(cs)I3 |
83  // CHECK: [[@LINE-2]]:23 | protocol/Swift | ExtProt2 | c:@M@modname@objc(pl)ExtProt2 |
84  // CHECK: [[@LINE-3]]:40 | enum/Swift | SomeEnum | c:@M@modname@E@SomeEnum |
85  [i3 meth];
86  // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth | c:@M@modname@objc(cs)I3(im)meth |
87  [i3 meth2];
88  // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth2 | c:@CM@modname@objc(cs)I3(im)meth2 |
89  [prot2 meth];
90  // CHECK: [[@LINE-1]]:10 | instance-method(protocol)/Swift | meth | c:@M@modname@objc(pl)ExtProt2(im)meth |
91  some = SomeEnumFirst;
92  // CHECK: [[@LINE-1]]:10 | enumerator/Swift | SomeEnumFirst | c:@M@modname@E@SomeEnum@SomeEnumFirst |
93}
94
95#pragma clang attribute PUSH_GEN_DECL("other_mod_for_cat")
96@interface I3(cat_other_mod)
97-(void)meth_other_mod;
98@end
99#pragma clang attribute pop
100
101void test3(I3 *i3) {
102  [i3 meth_other_mod];
103  // CHECK: [[@LINE-1]]:7 | instance-method/Swift | meth_other_mod | c:@CM@other_mod_for_cat@modname@objc(cs)I3(im)meth_other_mod |
104}
105