xref: /aosp_15_r20/external/clang/test/CodeGenCXX/exceptions-no-rtti.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -fno-rtti -fcxx-exceptions -fexceptions %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
2*67e74705SXin Li 
3*67e74705SXin Li // CHECK: @_ZTIN5test11AE = linkonce_odr constant
4*67e74705SXin Li // CHECK: @_ZTIN5test11BE = linkonce_odr constant
5*67e74705SXin Li // CHECK: @_ZTIN5test11CE = linkonce_odr constant
6*67e74705SXin Li // CHECK: @_ZTIN5test11DE = linkonce_odr constant
7*67e74705SXin Li // CHECK: @_ZTIPN5test11DE = linkonce_odr constant {{.*}} @_ZTIN5test11DE
8*67e74705SXin Li 
9*67e74705SXin Li // PR6974: this shouldn't crash
10*67e74705SXin Li namespace test0 {
11*67e74705SXin Li   class err {};
12*67e74705SXin Li 
f(void)13*67e74705SXin Li   void f(void) {
14*67e74705SXin Li     try {
15*67e74705SXin Li     } catch (err &) {
16*67e74705SXin Li     }
17*67e74705SXin Li   }
18*67e74705SXin Li }
19*67e74705SXin Li 
20*67e74705SXin Li namespace test1 {
21*67e74705SXin Li   // These classes have key functions defined out-of-line.  Under
22*67e74705SXin Li   // normal circumstances, we wouldn't generate RTTI for them; under
23*67e74705SXin Li   // -fno-rtti, we generate RTTI only when required by EH.  But
24*67e74705SXin Li   // everything gets hidden visibility because we assume that all
25*67e74705SXin Li   // users are also compiled under -fno-rtti and therefore will be
26*67e74705SXin Li   // emitting RTTI regardless of key function.
27*67e74705SXin Li   class A { virtual void foo(); };
28*67e74705SXin Li   class B { virtual void foo(); };
29*67e74705SXin Li   class C { virtual void foo(); };
30*67e74705SXin Li   class D { virtual void foo(); };
31*67e74705SXin Li 
32*67e74705SXin Li   void opaque();
33*67e74705SXin Li 
test0()34*67e74705SXin Li   void test0() {
35*67e74705SXin Li     throw A();
36*67e74705SXin Li   }
37*67e74705SXin Li 
test1()38*67e74705SXin Li   void test1() throw(B) {
39*67e74705SXin Li     opaque();
40*67e74705SXin Li   }
41*67e74705SXin Li 
test2()42*67e74705SXin Li   void test2() {
43*67e74705SXin Li     try {
44*67e74705SXin Li       opaque();
45*67e74705SXin Li     } catch (C&) {}
46*67e74705SXin Li   }
47*67e74705SXin Li 
test3(D * ptr)48*67e74705SXin Li   void test3(D *ptr) {
49*67e74705SXin Li     throw ptr;
50*67e74705SXin Li   };
51*67e74705SXin Li }
52