vtable-linkage.cpp revision 5794c9714a7d8c7eb8003d3e2616ab389ba9e45b
1// RUN: clang-cc %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s 2 3namespace { 4 struct A { 5 virtual void f() { } 6 }; 7} 8 9void f() { A b; } 10 11struct B { 12 B(); 13 virtual void f(); 14}; 15 16B::B() { } 17 18struct C { 19 C(); 20 virtual void f() { } 21}; 22 23C::C() { } 24 25struct D { 26 virtual void f(); 27}; 28 29void D::f() { } 30 31// B has a key function that is not defined in this translation unit so its vtable 32// has external linkage. 33// CHECK: @_ZTV1B = external constant 34 35// C has no key function, so its vtable should have weak_odr linkage. 36// CHECK: @_ZTV1C = weak_odr constant 37 38// D has a key function that is defined in this translation unit so its vtable is 39// defined in the translation unit. 40// CHECK: @_ZTV1D = constant 41 42// The A vtable should have internal linkage since it is inside an anonymous 43// namespace. 44// CHECK: @_ZTVN12_GLOBAL__N_11AE = internal constant 45