Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 2 | |
| 3 | // Simple key function test |
| 4 | struct testa { virtual void a(); }; |
| 5 | void testa::a() {} |
| 6 | |
| 7 | // Simple key function test |
| 8 | struct testb { virtual void a() {} }; |
| 9 | testb *testbvar = new testb; |
| 10 | |
| 11 | // Key function with out-of-line inline definition |
| 12 | struct testc { virtual void a(); }; |
| 13 | inline void testc::a() {} |
| 14 | |
John McCall | 3d640e6 | 2010-08-03 07:24:12 +0000 | [diff] [blame] | 15 | // Functions with inline specifier are not key functions (PR5705) |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 16 | struct testd { inline virtual void a(); }; |
| 17 | void testd::a() {} |
| 18 | |
John McCall | 3d640e6 | 2010-08-03 07:24:12 +0000 | [diff] [blame] | 19 | // Functions with inline specifier are not key functions (PR5705) |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 20 | struct teste { inline virtual void a(); }; |
| 21 | teste *testevar = new teste; |
| 22 | |
| 23 | // Key functions with namespace (PR5711) |
| 24 | namespace { |
| 25 | struct testf { virtual void a(); }; |
| 26 | } |
| 27 | void testf::a() {} |
| 28 | |
| 29 | // Key functions with namespace (PR5711) |
| 30 | namespace { |
| 31 | struct testg { virtual void a(); }; |
| 32 | } |
John McCall | 15e310a | 2011-02-19 02:53:41 +0000 | [diff] [blame] | 33 | void testg::a() {} |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 34 | testg *testgvar = new testg; |
| 35 | |
Douglas Gregor | ca4aa37 | 2010-05-14 04:08:48 +0000 | [diff] [blame] | 36 | struct X0 { virtual ~X0(); }; |
| 37 | struct X1 : X0 { |
| 38 | virtual void f(); |
| 39 | }; |
| 40 | |
| 41 | inline void X1::f() { } |
| 42 | |
| 43 | void use_X1(X1 *x1) { x1->f(); } |
| 44 | |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 45 | // FIXME: The checks are extremely difficult to get right when the globals |
| 46 | // aren't alphabetized |
Anders Carlsson | f502d93 | 2011-01-24 00:46:19 +0000 | [diff] [blame] | 47 | // CHECK: @_ZTV2X1 = linkonce_odr unnamed_addr constant |
Rafael Espindola | 9f959db | 2011-01-11 21:10:26 +0000 | [diff] [blame] | 48 | // CHECK: @_ZTV5testa = unnamed_addr constant [3 x i8*] [i8* null |
Anders Carlsson | f502d93 | 2011-01-24 00:46:19 +0000 | [diff] [blame] | 49 | // CHECK: @_ZTV5testc = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null |
Rafael Espindola | 9f959db | 2011-01-11 21:10:26 +0000 | [diff] [blame] | 50 | // CHECK: @_ZTVN12_GLOBAL__N_15testgE = internal unnamed_addr constant [3 x i8*] [i8* null |
Anders Carlsson | f502d93 | 2011-01-24 00:46:19 +0000 | [diff] [blame] | 51 | // 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 |