blob: 0ecd89805858086228be94868f2c753a314ee1c9 [file] [log] [blame]
Tim Northover9eca9f72013-01-26 15:27:54 +00001// RUN: %clang_cc1 -triple x86_64-none-linux-gnu %s -emit-llvm -o - | FileCheck %s
2// RUN: %clang_cc1 -triple arm-apple-darwin %s -emit-llvm -o - | FileCheck %s
Eli Friedman61eab882009-12-08 03:56:49 +00003
4// Simple key function test
5struct testa { virtual void a(); };
6void testa::a() {}
7
8// Simple key function test
9struct testb { virtual void a() {} };
10testb *testbvar = new testb;
11
12// Key function with out-of-line inline definition
13struct testc { virtual void a(); };
14inline void testc::a() {}
15
John McCall3d640e62010-08-03 07:24:12 +000016// Functions with inline specifier are not key functions (PR5705)
Eli Friedman61eab882009-12-08 03:56:49 +000017struct testd { inline virtual void a(); };
18void testd::a() {}
19
John McCall3d640e62010-08-03 07:24:12 +000020// Functions with inline specifier are not key functions (PR5705)
Eli Friedman61eab882009-12-08 03:56:49 +000021struct teste { inline virtual void a(); };
22teste *testevar = new teste;
23
24// Key functions with namespace (PR5711)
25namespace {
26 struct testf { virtual void a(); };
27}
28void testf::a() {}
29
30// Key functions with namespace (PR5711)
31namespace {
32 struct testg { virtual void a(); };
33}
John McCall15e310a2011-02-19 02:53:41 +000034void testg::a() {}
Eli Friedman61eab882009-12-08 03:56:49 +000035testg *testgvar = new testg;
36
Douglas Gregorca4aa372010-05-14 04:08:48 +000037struct X0 { virtual ~X0(); };
38struct X1 : X0 {
39 virtual void f();
40};
41
42inline void X1::f() { }
43
44void use_X1(X1 *x1) { x1->f(); }
45
Eli Friedman61eab882009-12-08 03:56:49 +000046// FIXME: The checks are extremely difficult to get right when the globals
47// aren't alphabetized
Anders Carlssonf502d932011-01-24 00:46:19 +000048// CHECK: @_ZTV2X1 = linkonce_odr unnamed_addr constant
Rafael Espindola9f959db2011-01-11 21:10:26 +000049// CHECK: @_ZTV5testa = unnamed_addr constant [3 x i8*] [i8* null
Anders Carlssonf502d932011-01-24 00:46:19 +000050// CHECK: @_ZTV5testc = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
Rafael Espindola9f959db2011-01-11 21:10:26 +000051// CHECK: @_ZTVN12_GLOBAL__N_15testgE = internal unnamed_addr constant [3 x i8*] [i8* null
Anders Carlssonf502d932011-01-24 00:46:19 +000052// CHECK: @_ZTV5teste = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
53// CHECK: @_ZTV5testb = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null