[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / InstallAPI / mismatching-objc-class-symbols.test
blobee35f81c58b3caa6964fb62d8a3cc66957728f7f
1 ; RUN: rm -rf %t
2 ; RUN: split-file %s %t
3 ; RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
4 ; RUN: yaml2obj %t/swift-objc-class.yaml -o %t/libswift-objc.dylib
6 // Try out dylib that only has 1 symbol for a ObjCClass, with no declarations in header. 
7 ; RUN: clang-installapi -target arm64-apple-macos14 -dynamiclib \
8 ; RUN: -install_name tmp.dylib --verify-against=%t/libswift-objc.dylib \
9 ; RUN: -I%t/usr/include %t/inputs.json -o %t/missing.tbd \
10 ; RUN: --verify-mode=ErrorsAndWarnings 2>&1 | FileCheck --check-prefix MISSING_DECL %s
11 ; RUN: llvm-readtapi --compare %t/missing.tbd %t/missing-expected.tbd 
13 // Try out a dylib that only has 1 symbol for a ObjCClass, 
14 // but a complete ObjCClass decl in header.
15 ; RUN: clang-installapi -target arm64-apple-macos14 -dynamiclib \
16 ; RUN: -install_name tmp.dylib --verify-against=%t/libswift-objc.dylib \
17 ; RUN: -I%t/usr/include %t/inputs.json -o %t/mismatching.tbd \
18 ; RUN: --verify-mode=Pedantic -DFULL_DECL 2>&1 | FileCheck --check-prefix MISMATCH_DECL %s
19 ; RUN: llvm-readtapi -compare %t/mismatching.tbd  %t/mismatching-expected.tbd
21 // Try out a dylib that only has 1 symbol for a ObjCClass, but is represented in header. 
22 ; RUN: clang-installapi -target arm64-apple-macos14 -dynamiclib \
23 ; RUN: -install_name tmp.dylib --verify-against=%t/libswift-objc.dylib \
24 ; RUN: -I%t/usr/include %t/inputs.json -o %t/matching.tbd \
25 ; RUN: --verify-mode=Pedantic \
26 ; RUN: -DHAS_META_DECL 2>&1 | FileCheck --allow-empty %s
28 ; MISSING_DECL:        violations found for arm64
29 ; MISSING_DECL-NEXT:   warning: no declaration was found for exported symbol 'Metaclass of Suggestion' in dynamic library
31 ; MISMATCH_DECL:       violations found for arm64-apple-macos14
32 ; MISMATCH_DECL:       warning: declaration has external linkage, but dynamic library doesn't have symbol 'Class of Suggestion'
34 ; CHECK-NOT:           error
35 ; CHECK-NOT:           warning 
38 ;--- usr/include/mismatch.h
39 #if HAS_META_DECL
40 int metaclass __asm("_OBJC_METACLASS_$_Suggestion");
41 #endif 
43 #if FULL_DECL
44 @interface Suggestion 
45 @end
46 #endif
48 ;--- inputs.json.in
50   "headers": [ {
51     "path" : "DSTROOT/usr/include/mismatch.h",
52     "type" : "public"
53   }
54   ],
55   "version": "3"
58 ;--- missing-expected.tbd
59 --- !tapi-tbd
60 tbd-version:     4
61 targets:         [ arm64-macos ]
62 flags:           [ not_app_extension_safe ]
63 install-name:    tmp.dylib
64 current-version: 0
65 compatibility-version: 0
66 ...
68 ;--- mismatching-expected.tbd
69 --- !tapi-tbd
70 tbd-version:     4
71 targets:         [ arm64-macos ]
72 flags:           [ not_app_extension_safe ]
73 install-name:    tmp.dylib
74 current-version: 0
75 compatibility-version: 0
76 exports:
77   - targets:         [ arm64-macos ]
78     objc-classes:    [ Suggestion ]
79 ...
81 ;--- swift-objc-class.yaml
82 --- !mach-o
83 FileHeader:
84   magic:           0xFEEDFACF
85   cputype:         0x100000C
86   cpusubtype:      0x0
87   filetype:        0x6
88   ncmds:           13
89   sizeofcmds:      752
90   flags:           0x100085
91   reserved:        0x0
92 LoadCommands:
93   - cmd:             LC_SEGMENT_64
94     cmdsize:         232
95     segname:         __TEXT
96     vmaddr:          0
97     vmsize:          16384
98     fileoff:         0
99     filesize:        16384
100     maxprot:         5
101     initprot:        5
102     nsects:          2
103     flags:           0
104     Sections:
105       - sectname:        __text
106         segname:         __TEXT
107         addr:            0x330
108         size:            0
109         offset:          0x330
110         align:           0
111         reloff:          0x0
112         nreloc:          0
113         flags:           0x80000000
114         reserved1:       0x0
115         reserved2:       0x0
116         reserved3:       0x0
117         content:         ''
118       - sectname:        __const
119         segname:         __TEXT
120         addr:            0x330
121         size:            1
122         offset:          0x330
123         align:           0
124         reloff:          0x0
125         nreloc:          0
126         flags:           0x0
127         reserved1:       0x0
128         reserved2:       0x0
129         reserved3:       0x0
130         content:         '61'
131   - cmd:             LC_SEGMENT_64
132     cmdsize:         72
133     segname:         __LINKEDIT
134     vmaddr:          16384
135     vmsize:          416
136     fileoff:         16384
137     filesize:        416
138     maxprot:         1
139     initprot:        1
140     nsects:          0
141     flags:           0
142   - cmd:             LC_DYLD_INFO_ONLY
143     cmdsize:         48
144     rebase_off:      0
145     rebase_size:     0
146     bind_off:        0
147     bind_size:       0
148     weak_bind_off:   0
149     weak_bind_size:  0
150     lazy_bind_off:   0
151     lazy_bind_size:  0
152     export_off:      16384
153     export_size:     40
154   - cmd:             LC_SYMTAB
155     cmdsize:         24
156     symoff:          16432
157     nsyms:           2
158     stroff:          16464
159     strsize:         48
160   - cmd:             LC_DYSYMTAB
161     cmdsize:         80
162     ilocalsym:       0
163     nlocalsym:       0
164     iextdefsym:      0
165     nextdefsym:      1
166     iundefsym:       1
167     nundefsym:       1
168     tocoff:          0
169     ntoc:            0
170     modtaboff:       0
171     nmodtab:         0
172     extrefsymoff:    0
173     nextrefsyms:     0
174     indirectsymoff:  0
175     nindirectsyms:   0
176     extreloff:       0
177     nextrel:         0
178     locreloff:       0
179     nlocrel:         0
180   - cmd:             LC_ID_DYLIB
181     cmdsize:         40
182     dylib:
183       name:            24
184       timestamp:       0
185       current_version: 0
186       compatibility_version: 0
187     Content:         tmp.dylib
188     ZeroPadBytes:    7
189   - cmd:             LC_UUID
190     cmdsize:         24
191     uuid:            4C4C4443-5555-3144-A142-97179769CBE0
192   - cmd:             LC_BUILD_VERSION
193     cmdsize:         32
194     platform:        1
195     minos:           917504
196     sdk:             983040
197     ntools:          1
198     Tools:
199       - tool:            4
200         version:         1245184
201   - cmd:             LC_LOAD_DYLIB
202     cmdsize:         96
203     dylib:
204       name:            24
205       timestamp:       0
206       current_version: 197656576
207       compatibility_version: 19660800
208     Content:         '/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation'
209     ZeroPadBytes:    3
210   - cmd:             LC_LOAD_DYLIB
211     cmdsize:         56
212     dylib:
213       name:            24
214       timestamp:       0
215       current_version: 88473600
216       compatibility_version: 65536
217     Content:         '/usr/lib/libSystem.B.dylib'
218     ZeroPadBytes:    6
219   - cmd:             LC_FUNCTION_STARTS
220     cmdsize:         16
221     dataoff:         16424
222     datasize:        8
223   - cmd:             LC_DATA_IN_CODE
224     cmdsize:         16
225     dataoff:         16432
226     datasize:        0
227   - cmd:             LC_CODE_SIGNATURE
228     cmdsize:         16
229     dataoff:         16512
230     datasize:        288
231 LinkEditData:
232   ExportTrie:
233     TerminalSize:    0
234     NodeOffset:      0
235     Name:            ''
236     Flags:           0x0
237     Address:         0x0
238     Other:           0x0
239     ImportName:      ''
240     Children:
241       - TerminalSize:    3
242         NodeOffset:      32
243         Name:            '_OBJC_METACLASS_$_Suggestion'
244         Flags:           0x0
245         Address:         0x330
246         Other:           0x0
247         ImportName:      ''
248   NameList:
249     - n_strx:          2
250       n_type:          0xF
251       n_sect:          2
252       n_desc:          0
253       n_value:         816
254     - n_strx:          31
255       n_type:          0x1
256       n_sect:          0
257       n_desc:          512
258       n_value:         0
259   StringTable:
260     - ' '
261     - '_OBJC_METACLASS_$_Suggestion'
262     - dyld_stub_binder
263   FunctionStarts:  [ 0x330 ]
265 // Generated from: 
266 // xcrun -sdk macosx clang tmp.c -dynamiclib -install_name tmp.dylib
267 // tmp.c: 
268 // __attribute__((visibility("default")))
269 // const char Meta __asm("_OBJC_METACLASS_$_Suggestion") = 'a';