Debian Codegraph @

clang/test/InstallAPI/diagnostics-cpp.test

raw
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
5 // RUN: yaml2obj %t/Mismatch.yaml -o %t/System/Library/Frameworks/MismatchCpp.framework/MismatchCpp
6
7 // RUN: not clang-installapi --target=arm64-apple-macos13 -x objective-c++ \
8 // RUN: -F %t/System/Library/Frameworks \
9 // RUN: -install_name /System/Library/Frameworks/MismatchCpp.framework/Versions/A/MismatchCpp \
10 // RUN: -current_version 1 -compatibility_version 1 %t/inputs.json \
11 // RUN: --verify-against=%t/System/Library/Frameworks/MismatchCpp.framework/MismatchCpp \
12 // RUN: --verify-mode=Pedantic -o %t/output.tbd --demangle 2> %t/errors.log
13 // RUN: FileCheck -input-file %t/errors.log %s
14
15 CHECK: warning: violations found for arm64-apple-macos13
16 CHECK: CPP.h:5:7: error: declaration has external linkage, but symbol has internal linkage in dynamic library 'vtable for Bar'
17 CHECK-NEXT: class Bar : Foo {
18 CHECK-NEXT: ^
19 CHECK-NEXT: CPP.h:5:7: error: declaration has external linkage, but symbol has internal linkage in dynamic library 'typeinfo for Bar'
20 CHECK-NEXT: CPP.h:5:7: error: declaration has external linkage, but symbol has internal linkage in dynamic library 'typeinfo name for Bar'
21 CHECK-NEXT: CPP.h:6:7: error: dynamic library symbol '(weak-def) Bar::init()' is weak defined, but its declaration is not
22 CHECK-NEXT: int init();
23 CHECK-NEXT: ^
24 CHECK-NEXT: warning: violations found for arm64
25 CHECK-NEXT: error: no declaration found for exported symbol 'int foo<unsigned int>(unsigned int)' in dynamic library
26
27 //--- inputs.json.in
28 {
29 "headers": [ {
30 "path" : "DSTROOT/System/Library/Frameworks/MismatchCpp.framework/Headers/CPP.h",
31 "type" : "public"
32 }
33 ],
34 "version": "3"
35 }
36
37 //--- System/Library/Frameworks/MismatchCpp.framework/Headers/CPP.h
38 class Foo {
39 virtual int init() = 0;
40 };
41
42 class Bar : Foo {
43 int init();
44 };
45
46 /// Created from:
47 // With LD flags: -exported_symbol,"__ZN3Bar4initEv" -exported_symbol,"__Z3fooIjEiT_"
48 // class Foo { virtual int init() = 0;};
49 //
50 // class Bar : Foo {int init() { return 1;}};
51 // Bar bar;
52 //
53 // template <typename T> int foo(T val) { return 1; }
54 // template <> int foo(unsigned val) { return 1; }
55
56 //--- Mismatch.yaml
57 --- !mach-o
58 FileHeader:
59 magic: 0xFEEDFACF
60 cputype: 0x100000C
61 cpusubtype: 0x0
62 filetype: 0x6
63 ncmds: 15
64 sizeofcmds: 1224
65 flags: 0x118085
66 reserved: 0x0
67 LoadCommands:
68 - cmd: LC_SEGMENT_64
69 cmdsize: 312
70 segname: __TEXT
71 vmaddr: 0
72 vmsize: 16384
73 fileoff: 0
74 filesize: 16384
75 maxprot: 5
76 initprot: 5
77 nsects: 3
78 flags: 0
79 Sections:
80 - sectname: __text
81 segname: __TEXT
82 addr: 0x10E8
83 size: 16
84 offset: 0x10E8
85 align: 2
86 reloff: 0x0
87 nreloc: 0
88 flags: 0x80000400
89 reserved1: 0x0
90 reserved2: 0x0
91 reserved3: 0x0
92 content: 20008052C0035FD620008052C0035FD6
93 - sectname: __const
94 segname: __TEXT
95 addr: 0x10F8
96 size: 10
97 offset: 0x10F8
98 align: 0
99 reloff: 0x0
100 nreloc: 0
101 flags: 0x0
102 reserved1: 0x0
103 reserved2: 0x0
104 reserved3: 0x0
105 content: 334261720033466F6F00
106 - sectname: __unwind_info
107 segname: __TEXT
108 addr: 0x1104
109 size: 4152
110 offset: 0x1104
111 align: 2
112 reloff: 0x0
113 nreloc: 0
114 flags: 0x0
115 reserved1: 0x0
116 reserved2: 0x0
117 reserved3: 0x0
118 content: 010000001C000000010000002000000000000000200000000200000000000002E81000003800000038000000F81000000000000038000000030000000C0001001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
119 - cmd: LC_SEGMENT_64
120 cmdsize: 232
121 segname: __DATA_CONST
122 vmaddr: 16384
123 vmsize: 16384
124 fileoff: 16384
125 filesize: 16384
126 maxprot: 3
127 initprot: 3
128 nsects: 2
129 flags: 16
130 Sections:
131 - sectname: __const
132 segname: __DATA_CONST
133 addr: 0x4000
134 size: 80
135 offset: 0x4000
136 align: 3
137 reloff: 0x0
138 nreloc: 0
139 flags: 0x0
140 reserved1: 0x0
141 reserved2: 0x0
142 reserved3: 0x0
143 content: 00000000000000002840000000000000F0100000000000001000000000000000FD100000000000801000000000000000F810000000000080000000000100000018400000000000000000000000000000
144 - sectname: __objc_imageinfo
145 segname: __DATA_CONST
146 addr: 0x4050
147 size: 8
148 offset: 0x4050
149 align: 0
150 reloff: 0x0
151 nreloc: 0
152 flags: 0x0
153 reserved1: 0x0
154 reserved2: 0x0
155 reserved3: 0x0
156 content: '0000000040000000'
157 - cmd: LC_SEGMENT_64
158 cmdsize: 152
159 segname: __DATA
160 vmaddr: 32768
161 vmsize: 16384
162 fileoff: 32768
163 filesize: 16384
164 maxprot: 3
165 initprot: 3
166 nsects: 1
167 flags: 0
168 Sections:
169 - sectname: __data
170 segname: __DATA
171 addr: 0x8000
172 size: 8
173 offset: 0x8000
174 align: 3
175 reloff: 0x0
176 nreloc: 0
177 flags: 0x0
178 reserved1: 0x0
179 reserved2: 0x0
180 reserved3: 0x0
181 content: '1040000000000000'
182 - cmd: LC_SEGMENT_64
183 cmdsize: 72
184 segname: __LINKEDIT
185 vmaddr: 49152
186 vmsize: 1104
187 fileoff: 49152
188 filesize: 1104
189 maxprot: 1
190 initprot: 1
191 nsects: 0
192 flags: 0
193 - cmd: LC_DYLD_INFO_ONLY
194 cmdsize: 48
195 rebase_off: 49152
196 rebase_size: 16
197 bind_off: 49168
198 bind_size: 96
199 weak_bind_off: 49264
200 weak_bind_size: 24
201 lazy_bind_off: 0
202 lazy_bind_size: 0
203 export_off: 49288
204 export_size: 48
205 - cmd: LC_SYMTAB
206 cmdsize: 24
207 symoff: 49344
208 nsyms: 11
209 stroff: 49520
210 strsize: 192
211 - cmd: LC_DYSYMTAB
212 cmdsize: 80
213 ilocalsym: 0
214 nlocalsym: 6
215 iextdefsym: 6
216 nextdefsym: 2
217 iundefsym: 8
218 nundefsym: 3
219 tocoff: 0
220 ntoc: 0
221 modtaboff: 0
222 nmodtab: 0
223 extrefsymoff: 0
224 nextrefsyms: 0
225 indirectsymoff: 0
226 nindirectsyms: 0
227 extreloff: 0
228 nextrel: 0
229 locreloff: 0
230 nlocrel: 0
231 - cmd: LC_ID_DYLIB
232 cmdsize: 96
233 dylib:
234 name: 24
235 timestamp: 0
236 current_version: 65536
237 compatibility_version: 65536
238 Content: '/System/Library/Frameworks/MismatchCpp.framework/Versions/A/MismatchCpp'
239 ZeroPadBytes: 1
240 - cmd: LC_UUID
241 cmdsize: 24
242 uuid: 4C4C44F3-5555-3144-A13F-B3FE15787197
243 - cmd: LC_BUILD_VERSION
244 cmdsize: 32
245 platform: 1
246 minos: 851968
247 sdk: 983040
248 ntools: 1
249 Tools:
250 - tool: 4
251 version: 1245184
252 - cmd: LC_LOAD_DYLIB
253 cmdsize: 48
254 dylib:
255 name: 24
256 timestamp: 0
257 current_version: 117985024
258 compatibility_version: 65536
259 Content: '/usr/lib/libc++.1.dylib'
260 ZeroPadBytes: 1
261 - cmd: LC_LOAD_DYLIB
262 cmdsize: 56
263 dylib:
264 name: 24
265 timestamp: 0
266 current_version: 88473600
267 compatibility_version: 65536
268 Content: '/usr/lib/libSystem.B.dylib'
269 ZeroPadBytes: 6
270 - cmd: LC_FUNCTION_STARTS
271 cmdsize: 16
272 dataoff: 49336
273 datasize: 8
274 - cmd: LC_DATA_IN_CODE
275 cmdsize: 16
276 dataoff: 49344
277 datasize: 0
278 - cmd: LC_CODE_SIGNATURE
279 cmdsize: 16
280 dataoff: 49712
281 datasize: 544
282 LinkEditData:
283 RebaseOpcodes:
284 - Opcode: REBASE_OPCODE_SET_TYPE_IMM
285 Imm: 1
286 - Opcode: REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
287 Imm: 1
288 ExtraData: [ 0x8 ]
289 - Opcode: REBASE_OPCODE_DO_REBASE_IMM_TIMES
290 Imm: 2
291 - Opcode: REBASE_OPCODE_ADD_ADDR_IMM_SCALED
292 Imm: 1
293 - Opcode: REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB
294 Imm: 0
295 ExtraData: [ 0x3, 0x8 ]
296 - Opcode: REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
297 Imm: 2
298 ExtraData: [ 0x0 ]
299 - Opcode: REBASE_OPCODE_DO_REBASE_IMM_TIMES
300 Imm: 1
301 - Opcode: REBASE_OPCODE_DONE
302 Imm: 0
303 BindOpcodes:
304 - Opcode: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
305 Imm: 0
306 Symbol: __ZTVN10__cxxabiv117__class_type_infoE
307 - Opcode: BIND_OPCODE_SET_TYPE_IMM
308 Imm: 1
309 Symbol: ''
310 - Opcode: BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
311 Imm: 1
312 Symbol: ''
313 - Opcode: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
314 Imm: 1
315 ULEBExtraData: [ 0x18 ]
316 Symbol: ''
317 - Opcode: BIND_OPCODE_SET_ADDEND_SLEB
318 Imm: 0
319 SLEBExtraData: [ 16 ]
320 Symbol: ''
321 - Opcode: BIND_OPCODE_DO_BIND
322 Imm: 0
323 Symbol: ''
324 - Opcode: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
325 Imm: 0
326 Symbol: __ZTVN10__cxxabiv121__vmi_class_type_infoE
327 - Opcode: BIND_OPCODE_SET_TYPE_IMM
328 Imm: 1
329 Symbol: ''
330 - Opcode: BIND_OPCODE_ADD_ADDR_ULEB
331 Imm: 0
332 ULEBExtraData: [ 0x8 ]
333 Symbol: ''
334 - Opcode: BIND_OPCODE_DO_BIND
335 Imm: 0
336 Symbol: ''
337 - Opcode: BIND_OPCODE_DONE
338 Imm: 0
339 Symbol: ''
340 WeakBindOpcodes:
341 - Opcode: BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM
342 Imm: 0
343 Symbol: __ZN3Bar4initEv
344 - Opcode: BIND_OPCODE_SET_TYPE_IMM
345 Imm: 1
346 Symbol: ''
347 - Opcode: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
348 Imm: 1
349 ULEBExtraData: [ 0x10 ]
350 Symbol: ''
351 - Opcode: BIND_OPCODE_DO_BIND
352 Imm: 0
353 Symbol: ''
354 - Opcode: BIND_OPCODE_DONE
355 Imm: 0
356 Symbol: ''
357 ExportTrie:
358 TerminalSize: 0
359 NodeOffset: 0
360 Name: ''
361 Flags: 0x0
362 Address: 0x0
363 Other: 0x0
364 ImportName: ''
365 Children:
366 - TerminalSize: 0
367 NodeOffset: 7
368 Name: __Z
369 Flags: 0x0
370 Address: 0x0
371 Other: 0x0
372 ImportName: ''
373 Children:
374 - TerminalSize: 3
375 NodeOffset: 35
376 Name: 3fooIjEiT_
377 Flags: 0x0
378 Address: 0x10E8
379 Other: 0x0
380 ImportName: ''
381 - TerminalSize: 3
382 NodeOffset: 40
383 Name: N3Bar4initEv
384 Flags: 0x4
385 Address: 0x10F0
386 Other: 0x0
387 ImportName: ''
388 NameList:
389 - n_strx: 32
390 n_type: 0x1E
391 n_sect: 4
392 n_desc: 0
393 n_value: 16384
394 - n_strx: 42
395 n_type: 0x1E
396 n_sect: 4
397 n_desc: 0
398 n_value: 16408
399 - n_strx: 52
400 n_type: 0x1E
401 n_sect: 4
402 n_desc: 0
403 n_value: 16424
404 - n_strx: 62
405 n_type: 0x1E
406 n_sect: 6
407 n_desc: 0
408 n_value: 32768
409 - n_strx: 67
410 n_type: 0x1E
411 n_sect: 2
412 n_desc: 0
413 n_value: 4344
414 - n_strx: 77
415 n_type: 0x1E
416 n_sect: 2
417 n_desc: 0
418 n_value: 4349
419 - n_strx: 2
420 n_type: 0xF
421 n_sect: 1
422 n_desc: 0
423 n_value: 4328
424 - n_strx: 16
425 n_type: 0xF
426 n_sect: 1
427 n_desc: 128
428 n_value: 4336
429 - n_strx: 87
430 n_type: 0x1
431 n_sect: 0
432 n_desc: 256
433 n_value: 0
434 - n_strx: 126
435 n_type: 0x1
436 n_sect: 0
437 n_desc: 256
438 n_value: 0
439 - n_strx: 169
440 n_type: 0x1
441 n_sect: 0
442 n_desc: 512
443 n_value: 0
444 StringTable:
445 - ' '
446 - __Z3fooIjEiT_
447 - __ZN3Bar4initEv
448 - __ZTV3Bar
449 - __ZTI3Foo
450 - __ZTI3Bar
451 - _bar
452 - __ZTS3Bar
453 - __ZTS3Foo
454 - __ZTVN10__cxxabiv117__class_type_infoE
455 - __ZTVN10__cxxabiv121__vmi_class_type_infoE
456 - dyld_stub_binder
457 - ''
458 - ''
459 - ''
460 - ''
461 - ''
462 - ''
463 FunctionStarts: [ 0x10E8, 0x10F0 ]
464 ...