19eca9f7da9166a9100020d3de19584216f95d67aTim Northover// RUN: %clang_cc1 -triple x86_64-none-linux-gnu %s -emit-llvm -o - | FileCheck %s
29eca9f7da9166a9100020d3de19584216f95d67aTim Northover// RUN: %clang_cc1 -triple arm-apple-darwin %s -emit-llvm -o - | FileCheck %s
361eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
461eab8872168af6eb1e0047a82901096cf145e27Eli Friedman// Simple key function test
561eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanstruct testa { virtual void a(); };
661eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanvoid testa::a() {}
761eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
861eab8872168af6eb1e0047a82901096cf145e27Eli Friedman// Simple key function test
961eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanstruct testb { virtual void a() {} };
1061eab8872168af6eb1e0047a82901096cf145e27Eli Friedmantestb *testbvar = new testb;
1161eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
1261eab8872168af6eb1e0047a82901096cf145e27Eli Friedman// Key function with out-of-line inline definition
1361eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanstruct testc { virtual void a(); };
1461eab8872168af6eb1e0047a82901096cf145e27Eli Friedmaninline void testc::a() {}
1561eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
163d640e606165daf2eaf18d52c0697f68daec106aJohn McCall// Functions with inline specifier are not key functions (PR5705)
1761eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanstruct testd { inline virtual void a(); };
1861eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanvoid testd::a() {}
1961eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
203d640e606165daf2eaf18d52c0697f68daec106aJohn McCall// Functions with inline specifier are not key functions (PR5705)
2161eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanstruct teste { inline virtual void a(); };
2261eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanteste *testevar = new teste;
2361eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
2461eab8872168af6eb1e0047a82901096cf145e27Eli Friedman// Key functions with namespace (PR5711)
2561eab8872168af6eb1e0047a82901096cf145e27Eli Friedmannamespace {
2661eab8872168af6eb1e0047a82901096cf145e27Eli Friedman  struct testf { virtual void a(); };
2761eab8872168af6eb1e0047a82901096cf145e27Eli Friedman}
2861eab8872168af6eb1e0047a82901096cf145e27Eli Friedmanvoid testf::a() {}
2961eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
3061eab8872168af6eb1e0047a82901096cf145e27Eli Friedman// Key functions with namespace (PR5711)
3161eab8872168af6eb1e0047a82901096cf145e27Eli Friedmannamespace {
3261eab8872168af6eb1e0047a82901096cf145e27Eli Friedman  struct testg { virtual void a(); };
3361eab8872168af6eb1e0047a82901096cf145e27Eli Friedman}
3415e310a3b970b64a84cb30f0005bc396b4d978cbJohn McCallvoid testg::a() {}
3561eab8872168af6eb1e0047a82901096cf145e27Eli Friedmantestg *testgvar = new testg;
3661eab8872168af6eb1e0047a82901096cf145e27Eli Friedman
37ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregorstruct X0 { virtual ~X0(); };
38ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregorstruct X1 : X0 {
39ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregor  virtual void f();
40ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregor};
41ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregor
42ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregorinline void X1::f() { }
43ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregor
440e2c34f92f00628d48968dfea096d36381f494cbStephen Hinesvoid use_X1() { X1 x1; }
45ca4aa379fcae53c50760cdf3632d8d801b795046Douglas Gregor
463ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar// CHECK-DAG: @_ZTV2X1 = linkonce_odr unnamed_addr constant
473ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar// CHECK-DAG: @_ZTV5testa = unnamed_addr constant [3 x i8*] [i8* null
483ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar// CHECK-DAG: @_ZTV5testc = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
493ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar// CHECK-DAG: @_ZTV5testb = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
503ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar// CHECK-DAG: @_ZTV5teste = linkonce_odr unnamed_addr constant [3 x i8*] [i8* null
513ea9e33ea25e0c2b12db56418ba3f994eb662c04Pirama Arumuga Nainar// CHECK-DAG: @_ZTVN12_GLOBAL__N_15testgE = internal unnamed_addr constant [3 x i8*] [i8* null
52