Tim Northover | 9eca9f7 | 2013-01-26 15:27:54 +0000 | [diff] [blame] | 1 | // 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 Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 3 | |
| 4 | // Simple key function test |
| 5 | struct testa { virtual void a(); }; |
| 6 | void testa::a() {} |
| 7 | |
| 8 | // Simple key function test |
| 9 | struct testb { virtual void a() {} }; |
| 10 | testb *testbvar = new testb; |
| 11 | |
| 12 | // Key function with out-of-line inline definition |
| 13 | struct testc { virtual void a(); }; |
| 14 | inline void testc::a() {} |
| 15 | |
John McCall | 3d640e6 | 2010-08-03 07:24:12 +0000 | [diff] [blame] | 16 | // Functions with inline specifier are not key functions (PR5705) |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 17 | struct testd { inline virtual void a(); }; |
| 18 | void testd::a() {} |
| 19 | |
John McCall | 3d640e6 | 2010-08-03 07:24:12 +0000 | [diff] [blame] | 20 | // Functions with inline specifier are not key functions (PR5705) |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 21 | struct teste { inline virtual void a(); }; |
| 22 | teste *testevar = new teste; |
| 23 | |
| 24 | // Key functions with namespace (PR5711) |
| 25 | namespace { |
| 26 | struct testf { virtual void a(); }; |
| 27 | } |
| 28 | void testf::a() {} |
| 29 | |
| 30 | // Key functions with namespace (PR5711) |
| 31 | namespace { |
| 32 | struct testg { virtual void a(); }; |
| 33 | } |
John McCall | 15e310a | 2011-02-19 02:53:41 +0000 | [diff] [blame] | 34 | void testg::a() {} |
Eli Friedman | 61eab88 | 2009-12-08 03:56:49 +0000 | [diff] [blame] | 35 | testg *testgvar = new testg; |
| 36 | |
Douglas Gregor | ca4aa37 | 2010-05-14 04:08:48 +0000 | [diff] [blame] | 37 | struct X0 { virtual ~X0(); }; |
| 38 | struct X1 : X0 { |
| 39 | virtual void f(); |
| 40 | }; |
| 41 | |
| 42 | inline void X1::f() { } |
| 43 | |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 44 | void use_X1() { X1 x1; } |
Douglas Gregor | ca4aa37 | 2010-05-14 04:08:48 +0000 | [diff] [blame] | 45 | |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 46 | // CHECK-DAG: @_ZTV2X1 = linkonce_odr unnamed_addr constant |
| 47 | // CHECK-DAG: @_ZTV5testa = unnamed_addr constant [3 x i8*] [i8* null |
| 48 | // CHECK-DAG: @_ZTV5testc = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null |
| 49 | // CHECK-DAG: @_ZTV5testb = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null |
| 50 | // CHECK-DAG: @_ZTV5teste = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null |
| 51 | // CHECK-DAG: @_ZTVN12_GLOBAL__N_15testgE = internal unnamed_addr constant [3 x i8*] [i8* null |