2 // RUN: split-file %s %t
3 // RUN: sed -e "s|DSTROOT|%/t|g" %t/inputs.json.in > %t/inputs.json
5 // Invoke C++ with no-rtti.
6 // RUN: clang-installapi -target arm64-apple-macos13.1 \
7 // RUN: -I%t/usr/include -I%t/usr/local/include -x c++ -dynamiclib \
8 // RUN: -install_name @rpath/lib/libcpp.dylib -fno-rtti \
9 // RUN: %t/inputs.json -o %t/no-rtti.tbd 2>&1 | FileCheck %s --allow-empty
11 // RUN: llvm-readtapi -compare %t/no-rtti.tbd \
12 // RUN: %t/expected-no-rtti.tbd 2>&1 | FileCheck %s --allow-empty
14 // Invoke C++ with rtti.
15 // RUN: clang-installapi -target arm64-apple-macos13.1 \
16 // RUN: -I%t/usr/include -I%t/usr/local/include -x c++ \
17 // RUN: -install_name @rpath/lib/libcpp.dylib -frtti -dynamiclib \
18 // RUN: %t/inputs.json -o %t/rtti.tbd 2>&1 | FileCheck %s --allow-empty
19 // RUN: llvm-readtapi -compare %t/rtti.tbd \
20 // RUN: %t/expected-rtti.tbd 2>&1 | FileCheck %s --allow-empty
23 // CHECK-NOT: warning:
25 //--- usr/include/basic.h
29 inline int foo(int x) { return x + 1; }
31 extern int bar(int x) { return x + 1; }
33 inline int baz(int x) {
34 static const int a[] = {1, 2, 3};
39 int cFunc(const char*);
44 static const int x = 0;
47 inline int func1(int x) { return x + 2; }
48 inline int func2(int x);
52 class __attribute__((visibility("hidden"))) BarI {
53 static const int x = 0;
56 inline int func1(int x) { return x + 2; }
57 inline int func2(int x);
61 int Bar::func2(int x) { return x + 3; }
62 inline int Bar::func3(int x) { return x + 4; }
64 int BarI::func2(int x) { return x + 3; }
65 inline int BarI::func3(int x) { return x + 4; }
68 //--- usr/local/include/vtable.h
69 // Simple test class with no virtual functions. There should be no vtable or
76 } // end namespace test1
78 // Simple test class with virtual function. There should be an external vtable
85 } // end namespace test2
87 // Abstract class with no sub classes. There should be no vtable or RTTI.
91 virtual ~Abstract() {}
92 virtual void run() = 0;
94 } // end namespace test3
96 // Abstract base class with a sub class. There should be weak-def RTTI for the
97 // abstract base class.
98 // The sub-class should have vtable and RTTI.
103 virtual void run() = 0;
106 class Sub : public Base {
110 } // end namespace test4
112 // Abstract base class with a sub class. Same as above, but with a user defined
113 // inlined destructor.
118 virtual void run() = 0;
121 class Sub : public Base {
126 } // end namespace test5
128 // Abstract base class with a sub class. Same as above, but with a different
129 // inlined key method.
134 virtual void run() = 0;
137 class Sub : public Base {
139 virtual void foo() {}
142 } // end namespace test6
144 // Abstract base class with a sub class. Overloaded method is implemented
145 // inline. No vtable or RTTI.
150 virtual bool run() = 0;
153 class Sub : public Base {
155 bool run() override { return true; }
157 } // end namespace test7
159 // Abstract base class with a sub class. Overloaded method has no inline
160 // attribute and is recognized as key method,
161 // but is later implemented inline. Weak-def RTTI only.
166 virtual void run() = 0;
169 class Sub : public Base {
174 inline void Sub::run() {}
175 } // end namespace test8
181 virtual void run1() = 0;
182 virtual void run2() = 0;
185 class Sub : public Base {
187 void run1() override {}
188 void run2() override;
191 inline void Sub::run2() {}
192 } // end namespace test9
198 virtual void run1() = 0;
199 virtual void run2() = 0;
202 class Sub : public Base {
204 void run1() override {}
205 inline void run2() override;
209 } // end namespace test10
215 virtual void run1() = 0;
216 virtual void run2() = 0;
217 virtual void run3() = 0;
220 class Sub : public Base {
222 void run1() override {}
223 void run2() override;
224 void run3() override;
227 inline void Sub::run2() {}
228 } // end namespace test11
231 template <class T> class Simple {
233 virtual void foo() {}
235 extern template class Simple<int>;
236 } // end namespace test12
242 virtual void run1() = 0;
243 virtual void run2() {};
244 virtual void run3(); // key function.
247 class Sub : public Base {
249 void run1() override {}
250 void run2() override {}
253 } // end namespace test13
257 class __attribute__((visibility("hidden"))) Base
261 virtual ~Base(); // keyfunction.
262 virtual void run1() const = 0;
265 class Sub : public Base
270 virtual void run1() const;
274 } // end namespace test14
281 virtual void run() {};
287 virtual void run1() {};
290 class Sub : public Base, public Base1 {
295 void run1() override;
298 class Sub1 : public Base, public Base1 {
303 void run1() override;
306 } // end namespace test15
308 //--- usr/local/include/templates.h
312 namespace templates {
314 // Full specialization.
315 template <class T> int foo1(T a) { return 1; }
316 template <> int foo1<int>(int a);
317 extern template int foo1<short>(short a);
319 template <class T> int foo2(T a);
321 // Partial specialization.
322 template <class A, class B> class Partial {
323 static int run(A a, B b) { return a + b; }
326 template <class A> class Partial<A, int> {
327 static int run(A a, int b) { return a - b; }
330 template <class T> class Foo {
336 template <class T> class Bar {
341 inline int bazinga() { return 7; }
344 extern template class Bar<int>;
350 template <class T> int buzz(T a);
352 float implicit() const { return foo1(0.0f); }
355 template <class T> int Bazz::buzz(T a) { return sizeof(T); }
357 template <class T> struct S { static int x; };
359 template <class T> int S<T>::x = 0;
361 } // end namespace templates.
369 "path" : "DSTROOT/usr/include/basic.h",
373 "path" : "DSTROOT/usr/local/include/vtable.h",
377 "path" : "DSTROOT/usr/local/include/templates.h",
384 //--- expected-no-rtti.tbd
387 "compatibility_versions": [
392 "current_versions": [
397 "exported_symbols": [
401 "__ZTVN6test143SubE", "__ZTVN6test113SubE", "__ZTVN5test26SimpleE",
402 "__ZTVN5test53SubE", "__ZTVN6test154Sub1E", "__ZTVN6test153SubE",
403 "__ZN3Bar1yE", "__ZTVN5test43SubE", "__ZTVN5test63SubE",
404 "__ZTVN6test134BaseE"
407 "__ZTVN6test126SimpleIiEE"
412 "__ZN6test153Sub3runEv", "__ZN6test154Sub13runEv",
413 "__Z3bari", "__ZThn8_N6test153SubD1Ev",
414 "__ZNK6test143Sub4run1Ev", "__ZN6test154Sub14run1Ev",
415 "__ZThn8_N6test153Sub4run1Ev", "__ZN6test143SubD1Ev",
416 "__ZN6test134Base4run3Ev", "__ZN5test16Simple3runEv",
417 "__ZN5test43Sub3runEv", "__ZN6test113Sub4run3Ev", "__ZN6test153SubD2Ev",
418 "__ZN5test53Sub3runEv", "__ZN6test153SubD1Ev", "__ZN6test143SubC1Ev",
419 "__ZN9templates4foo1IiEEiT_", "__ZN6test143SubC2Ev", "__ZN5test63Sub3runEv",
420 "__ZN5test26Simple3runEv", "__ZN6test153SubD0Ev",
421 "__ZN6test143SubD2Ev", "__ZN6test153Sub4run1Ev", "__ZN6test143SubD0Ev",
422 "__ZThn8_N6test153SubD0Ev", "__ZThn8_N6test154Sub14run1Ev", "_cFunc"
425 "__ZN9templates3BarIiED2Ev", "__ZN9templates3BarIiEC2Ev",
426 "__ZN9templates3BarIiEC1Ev", "__ZN9templates3BarIiED1Ev",
427 "__ZN6test126SimpleIiE3fooEv", "__ZN9templates3BarIiE7bazingaEv",
428 "__ZN9templates4foo1IsEEiT_"
436 "not_app_extension_safe"
442 "name": "@rpath/lib/libcpp.dylib"
447 "min_deployment": "13.1",
448 "target": "arm64-macos"
452 "tapi_tbd_version": 5
455 //--- expected-rtti.tbd
458 "compatibility_versions": [
463 "current_versions": [
468 "exported_symbols": [
472 "__ZTVN6test143SubE", "__ZTIN5test63SubE", "__ZTSN5test26SimpleE",
473 "__ZTIN6test153SubE", "__ZTVN6test113SubE", "__ZTIN5test43SubE",
474 "__ZTIN6test134BaseE", "__ZTVN5test26SimpleE", "__ZTIN5test26SimpleE",
475 "__ZTSN6test134BaseE", "__ZTVN6test154Sub1E", "__ZTVN5test43SubE",
476 "__ZTVN5test63SubE", "__ZTSN5test43SubE", "__ZTSN6test113SubE",
477 "__ZTIN6test154Sub1E", "__ZTSN6test153SubE", "__ZTSN5test63SubE",
478 "__ZTSN6test154Sub1E", "__ZTIN6test113SubE", "__ZTSN6test143SubE",
479 "__ZTVN5test53SubE", "__ZTIN6test143SubE", "__ZTVN6test153SubE",
480 "__ZTIN5test53SubE", "__ZN3Bar1yE", "__ZTVN6test134BaseE",
484 "__ZTVN6test126SimpleIiEE"
489 "__ZN6test154Sub13runEv", "__ZN6test153Sub3runEv", "__ZNK6test143Sub4run1Ev",
490 "__ZN6test134Base4run3Ev", "__ZN5test16Simple3runEv", "__ZN6test153SubD2Ev",
491 "__ZN6test143SubC2Ev", "__ZN5test63Sub3runEv", "__ZN6test153SubD0Ev",
492 "__ZN6test143SubD2Ev", "__ZThn8_N6test154Sub14run1Ev",
493 "__ZThn8_N6test153SubD0Ev", "__Z3bari", "__ZThn8_N6test153SubD1Ev",
494 "__ZN6test154Sub14run1Ev", "__ZThn8_N6test153Sub4run1Ev",
495 "__ZN6test143SubD1Ev", "__ZN5test43Sub3runEv",
496 "__ZN6test113Sub4run3Ev", "__ZN5test53Sub3runEv", "__ZN6test143SubC1Ev",
497 "__ZN6test153SubD1Ev", "__ZN9templates4foo1IiEEiT_", "__ZN5test26Simple3runEv",
498 "__ZN6test153Sub4run1Ev", "__ZN6test143SubD0Ev", "_cFunc"
501 "__ZN9templates3BarIiEC2Ev", "__ZN9templates3BarIiEC1Ev",
502 "__ZN9templates3BarIiED1Ev", "__ZN6test126SimpleIiE3fooEv",
503 "__ZN9templates4foo1IsEEiT_", "__ZN9templates3BarIiED2Ev",
504 "__ZN9templates3BarIiE7bazingaEv"
512 "not_app_extension_safe"
518 "name": "@rpath/lib/libcpp.dylib"
523 "min_deployment": "13.1",
524 "target": "arm64-macos"
528 "tapi_tbd_version": 5