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