vtable-available-externally.cpp revision 01de7a44cea9f77cbcda65faad8edc8b48a3b617
1// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o %t 2// RUN: FileCheck --check-prefix=CHECK-TEST1 %s < %t 3// RUN: FileCheck --check-prefix=CHECK-TEST2 %s < %t 4 5#include <typeinfo> 6 7// Test1::A's key function (f) is not defined in this translation unit, but in 8// order to devirtualize calls, we emit the class related data with 9// available_externally linkage. 10 11// CHECK-TEST1: @_ZTVN5Test11AE = available_externally 12// CHECK-TEST1: @_ZTSN5Test11AE = available_externally 13// CHECK-TEST1: @_ZTIN5Test11AE = available_externally 14namespace Test1 { 15 16struct A { 17 A(); 18 virtual void f(); 19 virtual ~A() { } 20}; 21 22A::A() { } 23 24void f(A* a) { 25 a->f(); 26}; 27 28// CHECK: define void @_ZN5Test11gEv 29// CHECK: call void @_ZN5Test11A1fEv 30void g() { 31 A a; 32 f(&a); 33} 34 35} 36 37// Test2::A's key function (f) is defined in this translation unit, but when 38// we're doing codegen for the typeid(A) call, we don't know that yet. 39// This tests mainly that the typeinfo and typename constants have their linkage 40// updated correctly. 41 42// CHECK-TEST2: @_ZTSN5Test21AE = constant 43// CHECK-TEST2: @_ZTIN5Test21AE = unnamed_addr constant 44// CHECK-TEST2: @_ZTVN5Test21AE = unnamed_addr constant 45namespace Test2 { 46 struct A { 47 virtual void f(); 48 }; 49 50 const std::type_info &g() { 51 return typeid(A); 52 }; 53 54 void A::f() { } 55} 56