[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / InstallAPI / alias_list.test
blobaba7e395cca95947e41d7254d2134661beb99150
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/AliasList.yaml -o %t/Frameworks/AliasList.framework/AliasList
6 ; RUN: clang-installapi --target=x86_64-apple-macos13 \
7 ; RUN: -alias_list %t/aliases.txt \
8 ; RUN: -install_name /System/Library/Frameworks/AliasList.framework/Versions/A/AliasList \
9 ; RUN: -current_version 1 -compatibility_version 1 \
10 ; RUN: -F%t/Frameworks -ObjC %t/inputs.json --verify-mode=Pedantic \ 
11 ; RUN: --verify-against=%t/Frameworks/AliasList.framework/AliasList \
12 ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s  \
13 ; RUN: --implicit-check-not=error --implicit-check-not=warning
14 ; RUN: llvm-readtapi -compare %t/expected.tbd %t/AliasList.tbd
16 // Check error handling.
17 ; RUN: not clang-installapi --target=x86_64-apple-macos13 \
18 ; RUN: -alias_list %t/invalid.txt \
19 ; RUN: -install_name /System/Library/Frameworks/AliasList.framework/Versions/A/AliasList \
20 ; RUN: -current_version 1 -compatibility_version 1 \
21 ; RUN: -F%t/Frameworks -ObjC %t/inputs.json --verify-mode=Pedantic \ 
22 ; RUN: --verify-against=%t/Frameworks/AliasList.framework/AliasList \
23 ; RUN: -o %t/AliasList.tbd 2>&1 | FileCheck -allow-empty %s  \
24 ; RUN: --check-prefix=INVALID
26 ; INVALID: error: could not read symbol alias input list {{.*}}invalid.txt': invalid input format: missing alias for: _hidden
28 ;--- Frameworks/AliasList.framework/Headers/AliasList.h
29 // simple alias from one symbol to another.
30 extern int simple_symbol;
31 extern int alias_symbol;
33 // This symbol comes from the alias file.
34 extern int exported_symbol;
36 // This symbol was moved here and has several special hide symbols in the alias
37 // file.
38 extern int moved_here_symbol;
40 // This alias is public, whereas the source is private.
41 extern int public_symbol;
43 ;--- Frameworks/AliasList.framework/PrivateHeaders/AliasList_Private.h
44 // This is a private symbol that has a public alias.
45 extern int private_symbol;
47 ;--- aliases.txt
48 # comment
49 _simple_symbol _alias_symbol
50 # test multiple space characters separated symbol and alias
51 _hidden_symbol      _exported_symbol  # test inline comment with spaces
52 # test tab character separated symbol and alias
53 _moved_here_symbol      $ld$hide$os10.4$_moved_here_symbol# test inline comment without spaces
54 # test trailing space character
55 _moved_here_symbol $ld$hide$os10.5$_moved_here_symbol 
56 # test trailing tab character
57 _moved_here_symbol $ld$hide$os10.6$_moved_here_symbol   
58 _private_symbol _public_symbol
60 ;--- invalid.txt
61 # comment
62 _simple_symbol _alias_symbol
63 _hidden # no matching
65 ;--- expected.tbd
67   "main_library": {
68     "exported_symbols": [
69       {
70         "data": {
71           "global": [
72             "_exported_symbol", "_simple_symbol", "_moved_here_symbol",
73             "$ld$hide$os10.6$_moved_here_symbol", "$ld$hide$os10.4$_moved_here_symbol",
74             "$ld$hide$os10.5$_moved_here_symbol", "_public_symbol",
75             "_private_symbol", "_alias_symbol"
76           ]
77         }
78       }
79     ],
80     "flags": [
81       {
82         "attributes": [
83           "not_app_extension_safe"
84         ]
85       }
86     ],
87     "install_names": [
88       {
89         "name": "/System/Library/Frameworks/AliasList.framework/Versions/A/AliasList"
90       }
91     ],
92     "target_info": [
93       {
94         "min_deployment": "13",
95         "target": "x86_64-macos"
96       }
97     ]
98   },
99   "tapi_tbd_version": 5
102 ;--- AliasList.yaml
103 --- !mach-o
104 FileHeader:
105   magic:           0xFEEDFACF
106   cputype:         0x1000007
107   cpusubtype:      0x3
108   filetype:        0x6
109   ncmds:           13
110   sizeofcmds:      920
111   flags:           0x100085
112   reserved:        0x0
113 LoadCommands:
114   - cmd:             LC_SEGMENT_64
115     cmdsize:         152
116     segname:         __TEXT
117     vmaddr:          0
118     vmsize:          4096
119     fileoff:         0
120     filesize:        4096
121     maxprot:         5
122     initprot:        5
123     nsects:          1
124     flags:           0
125     Sections:
126       - sectname:        __text
127         segname:         __TEXT
128         addr:            0xBB8
129         size:            0
130         offset:          0xBB8
131         align:           0
132         reloff:          0x0
133         nreloc:          0
134         flags:           0x80000000
135         reserved1:       0x0
136         reserved2:       0x0
137         reserved3:       0x0
138         content:         ''
139   - cmd:             LC_SEGMENT_64
140     cmdsize:         152
141     segname:         __DATA_CONST
142     vmaddr:          4096
143     vmsize:          4096
144     fileoff:         4096
145     filesize:        4096
146     maxprot:         3
147     initprot:        3
148     nsects:          1
149     flags:           16
150     Sections:
151       - sectname:        __objc_imageinfo
152         segname:         __DATA_CONST
153         addr:            0x1000
154         size:            8
155         offset:          0x1000
156         align:           0
157         reloff:          0x0
158         nreloc:          0
159         flags:           0x0
160         reserved1:       0x0
161         reserved2:       0x0
162         reserved3:       0x0
163         content:         '0000000040000000'
164   - cmd:             LC_SEGMENT_64
165     cmdsize:         152
166     segname:         __DATA
167     vmaddr:          8192
168     vmsize:          4096
169     fileoff:         8192
170     filesize:        0
171     maxprot:         3
172     initprot:        3
173     nsects:          1
174     flags:           0
175     Sections:
176       - sectname:        __common
177         segname:         __DATA
178         addr:            0x2000
179         size:            40
180         offset:          0x0
181         align:           2
182         reloff:          0x0
183         nreloc:          0
184         flags:           0x1
185         reserved1:       0x0
186         reserved2:       0x0
187         reserved3:       0x0
188   - cmd:             LC_SEGMENT_64
189     cmdsize:         72
190     segname:         __LINKEDIT
191     vmaddr:          12288
192     vmsize:          672
193     fileoff:         8192
194     filesize:        672
195     maxprot:         1
196     initprot:        1
197     nsects:          0
198     flags:           0
199   - cmd:             LC_DYLD_INFO_ONLY
200     cmdsize:         48
201     rebase_off:      0
202     rebase_size:     0
203     bind_off:        0
204     bind_size:       0
205     weak_bind_off:   0
206     weak_bind_size:  0
207     lazy_bind_off:   0
208     lazy_bind_size:  0
209     export_off:      8192
210     export_size:     248
211   - cmd:             LC_SYMTAB
212     cmdsize:         24
213     symoff:          8448
214     nsyms:           11
215     stroff:          8624
216     strsize:         240
217   - cmd:             LC_DYSYMTAB
218     cmdsize:         80
219     ilocalsym:       0
220     nlocalsym:       1
221     iextdefsym:      1
222     nextdefsym:      9
223     iundefsym:       10
224     nundefsym:       1
225     tocoff:          0
226     ntoc:            0
227     modtaboff:       0
228     nmodtab:         0
229     extrefsymoff:    0
230     nextrefsyms:     0
231     indirectsymoff:  0
232     nindirectsyms:   0
233     extreloff:       0
234     nextrel:         0
235     locreloff:       0
236     nlocrel:         0
237   - cmd:             LC_ID_DYLIB
238     cmdsize:         96
239     dylib:
240       name:            24
241       timestamp:       0
242       current_version: 65536
243       compatibility_version: 65536
244     Content:         '/System/Library/Frameworks/AliasList.framework/Versions/A/AliasList'
245     ZeroPadBytes:    5
246   - cmd:             LC_UUID
247     cmdsize:         24
248     uuid:            4C4C4468-5555-3144-A123-B0FDB87F9813
249   - cmd:             LC_BUILD_VERSION
250     cmdsize:         32
251     platform:        1
252     minos:           851968
253     sdk:             983040
254     ntools:          1
255     Tools:
256       - tool:            4
257         version:         1245184
258   - cmd:             LC_LOAD_DYLIB
259     cmdsize:         56
260     dylib:
261       name:            24
262       timestamp:       0
263       current_version: 88539136
264       compatibility_version: 65536
265     Content:         '/usr/lib/libSystem.B.dylib'
266     ZeroPadBytes:    6
267   - cmd:             LC_FUNCTION_STARTS
268     cmdsize:         16
269     dataoff:         8440
270     datasize:        8
271   - cmd:             LC_DATA_IN_CODE
272     cmdsize:         16
273     dataoff:         8448
274     datasize:        0
275 LinkEditData:
276   ExportTrie:
277     TerminalSize:    0
278     NodeOffset:      0
279     Name:            ''
280     Flags:           0x0
281     Address:         0x0
282     Other:           0x0
283     ImportName:      ''
284     Children:
285       - TerminalSize:    0
286         NodeOffset:      21
287         Name:            '$ld$hide$os10.'
288         Flags:           0x0
289         Address:         0x0
290         Other:           0x0
291         ImportName:      ''
292         Children:
293           - TerminalSize:    3
294             NodeOffset:      89
295             Name:            '4$_moved_here_symbol'
296             Flags:           0x0
297             Address:         0x2000
298             Other:           0x0
299             ImportName:      ''
300           - TerminalSize:    3
301             NodeOffset:      94
302             Name:            '6$_moved_here_symbol'
303             Flags:           0x0
304             Address:         0x2008
305             Other:           0x0
306             ImportName:      ''
307           - TerminalSize:    3
308             NodeOffset:      99
309             Name:            '5$_moved_here_symbol'
310             Flags:           0x0
311             Address:         0x2004
312             Other:           0x0
313             ImportName:      ''
314       - TerminalSize:    0
315         NodeOffset:      104
316         Name:            _
317         Flags:           0x0
318         Address:         0x0
319         Other:           0x0
320         ImportName:      ''
321         Children:
322           - TerminalSize:    3
323             NodeOffset:      179
324             Name:            alias_symbol
325             Flags:           0x0
326             Address:         0x2024
327             Other:           0x0
328             ImportName:      ''
329           - TerminalSize:    0
330             NodeOffset:      184
331             Name:            p
332             Flags:           0x0
333             Address:         0x0
334             Other:           0x0
335             ImportName:      ''
336             Children:
337               - TerminalSize:    3
338                 NodeOffset:      217
339                 Name:            ublic_symbol
340                 Flags:           0x0
341                 Address:         0x2020
342                 Other:           0x0
343                 ImportName:      ''
344               - TerminalSize:    3
345                 NodeOffset:      222
346                 Name:            rivate_symbol
347                 Flags:           0x0
348                 Address:         0x2018
349                 Other:           0x0
350                 ImportName:      ''
351           - TerminalSize:    3
352             NodeOffset:      227
353             Name:            simple_symbol
354             Flags:           0x0
355             Address:         0x200C
356             Other:           0x0
357             ImportName:      ''
358           - TerminalSize:    3
359             NodeOffset:      232
360             Name:            moved_here_symbol
361             Flags:           0x0
362             Address:         0x2014
363             Other:           0x0
364             ImportName:      ''
365           - TerminalSize:    3
366             NodeOffset:      237
367             Name:            exported_symbol
368             Flags:           0x0
369             Address:         0x201C
370             Other:           0x0
371             ImportName:      ''
372   NameList:
373     - n_strx:          122
374       n_type:          0x1E
375       n_sect:          3
376       n_desc:          0
377       n_value:         8208
378     - n_strx:          2
379       n_type:          0xF
380       n_sect:          3
381       n_desc:          0
382       n_value:         8192
383     - n_strx:          37
384       n_type:          0xF
385       n_sect:          3
386       n_desc:          0
387       n_value:         8196
388     - n_strx:          72
389       n_type:          0xF
390       n_sect:          3
391       n_desc:          0
392       n_value:         8200
393     - n_strx:          107
394       n_type:          0xF
395       n_sect:          3
396       n_desc:          0
397       n_value:         8204
398     - n_strx:          137
399       n_type:          0xF
400       n_sect:          3
401       n_desc:          0
402       n_value:         8212
403     - n_strx:          156
404       n_type:          0xF
405       n_sect:          3
406       n_desc:          0
407       n_value:         8216
408     - n_strx:          172
409       n_type:          0xF
410       n_sect:          3
411       n_desc:          0
412       n_value:         8220
413     - n_strx:          189
414       n_type:          0xF
415       n_sect:          3
416       n_desc:          0
417       n_value:         8224
418     - n_strx:          204
419       n_type:          0xF
420       n_sect:          3
421       n_desc:          0
422       n_value:         8228
423     - n_strx:          218
424       n_type:          0x1
425       n_sect:          0
426       n_desc:          256
427       n_value:         0
428   StringTable:
429     - ' '
430     - '$ld$hide$os10.4$_moved_here_symbol'
431     - '$ld$hide$os10.5$_moved_here_symbol'
432     - '$ld$hide$os10.6$_moved_here_symbol'
433     - _simple_symbol
434     - _hidden_symbol
435     - _moved_here_symbol
436     - _private_symbol
437     - _exported_symbol
438     - _public_symbol
439     - _alias_symbol
440     - dyld_stub_binder
441     - ''
442     - ''
443     - ''
444     - ''
445     - ''
448 ;--- inputs.json.in
450   "headers": [ 
451   {
452     "path" : "DSTROOT/Frameworks/AliasList.framework/Headers/AliasList.h",
453     "type" : "public"
454   }, 
455   {
456     "path" : "DSTROOT/Frameworks/AliasList.framework/PrivateHeaders/AliasList_Private.h",
457     "type" : "private"
458   }
459   ],
460   "version": "3"