xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/rtti-visibility.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -emit-llvm -o %t
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fhidden-weak-vtables -emit-llvm -o %t.hidden
3*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-TEST1 %s < %t
4*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-TEST2 %s < %t
5*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-TEST2-HIDDEN %s < %t.hidden
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc #include <typeinfo>
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc namespace Test1 {
10*f4a2713aSLionel Sambuc   // A is explicitly marked hidden, so all RTTI data should also be marked hidden.
11*f4a2713aSLionel Sambuc   // CHECK-TEST1: @_ZTSN5Test11AE = linkonce_odr hidden constant
12*f4a2713aSLionel Sambuc   // CHECK-TEST1: @_ZTIN5Test11AE = linkonce_odr hidden unnamed_addr constant
13*f4a2713aSLionel Sambuc   // CHECK-TEST1: @_ZTSPN5Test11AE = linkonce_odr hidden constant
14*f4a2713aSLionel Sambuc   // CHECK-TEST1: @_ZTIPN5Test11AE = linkonce_odr hidden unnamed_addr constant
15*f4a2713aSLionel Sambuc   struct __attribute__((visibility("hidden"))) A { };
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc   void f() {
18*f4a2713aSLionel Sambuc     (void)typeid(A);
19*f4a2713aSLionel Sambuc     (void)typeid(A *);
20*f4a2713aSLionel Sambuc   }
21*f4a2713aSLionel Sambuc }
22*f4a2713aSLionel Sambuc 
23*f4a2713aSLionel Sambuc namespace Test2 {
24*f4a2713aSLionel Sambuc   // A is weak, so its linkage should be linkoce_odr, but not marked hidden.
25*f4a2713aSLionel Sambuc   // CHECK-TEST2: @_ZTSN5Test21AE = linkonce_odr constant
26*f4a2713aSLionel Sambuc   // CHECK-TEST2: @_ZTIN5Test21AE = linkonce_odr unnamed_addr constant
27*f4a2713aSLionel Sambuc   struct A { };
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc   // With -fhidden-weak-vtables, the typeinfo for A is marked hidden, but not its name.
30*f4a2713aSLionel Sambuc   // CHECK-TEST2-HIDDEN: _ZTSN5Test21AE = linkonce_odr constant
31*f4a2713aSLionel Sambuc   // CHECK-TEST2-HIDDEN: @_ZTIN5Test21AE = linkonce_odr hidden unnamed_addr constant
32*f4a2713aSLionel Sambuc   void f() {
33*f4a2713aSLionel Sambuc     (void)typeid(A);
34*f4a2713aSLionel Sambuc   }
35*f4a2713aSLionel Sambuc }
36