Anders Carlsson | 4bdbc0c | 2011-04-11 14:13:40 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s |
| 2 | #include <typeinfo> |
| 3 | |
Anders Carlsson | 3a01693 | 2011-04-17 23:33:40 +0000 | [diff] [blame] | 4 | namespace Test1 { |
| 5 | |
Anders Carlsson | 4bdbc0c | 2011-04-11 14:13:40 +0000 | [diff] [blame] | 6 | // PR7400 |
| 7 | struct A { virtual void f(); }; |
| 8 | |
Richard Smith | 47d2145 | 2011-12-27 12:18:28 +0000 | [diff] [blame] | 9 | // CHECK: @_ZN5Test16int_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIi to %"class.std::type_info"*), align 8 |
| 10 | const std::type_info &int_ti = typeid(int); |
| 11 | |
| 12 | // CHECK: @_ZN5Test14A_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIN5Test11AE to %"class.std::type_info"*), align 8 |
| 13 | const std::type_info &A_ti = typeid(const volatile A &); |
| 14 | |
| 15 | volatile char c; |
| 16 | |
| 17 | // CHECK: @_ZN5Test14c_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIc to %"class.std::type_info"*), align 8 |
| 18 | const std::type_info &c_ti = typeid(c); |
| 19 | |
| 20 | extern const double &d; |
| 21 | |
| 22 | // CHECK: @_ZN5Test14d_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTId to %"class.std::type_info"*), align 8 |
| 23 | const std::type_info &d_ti = typeid(d); |
| 24 | |
| 25 | extern A &a; |
| 26 | |
| 27 | // CHECK: @_ZN5Test14a_tiE = global |
| 28 | const std::type_info &a_ti = typeid(a); |
| 29 | |
Anders Carlsson | 3a01693 | 2011-04-17 23:33:40 +0000 | [diff] [blame] | 30 | // CHECK: define i8* @_ZN5Test11fEv |
Anders Carlsson | 4bdbc0c | 2011-04-11 14:13:40 +0000 | [diff] [blame] | 31 | const char *f() { |
| 32 | try { |
| 33 | // CHECK: br i1 |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 34 | // CHECK: invoke void @__cxa_bad_typeid() [[NR:#[0-9]+]] |
Anders Carlsson | 4bdbc0c | 2011-04-11 14:13:40 +0000 | [diff] [blame] | 35 | return typeid(*static_cast<A *>(0)).name(); |
| 36 | } catch (...) { |
Bill Wendling | 285cfd8 | 2011-09-19 20:31:14 +0000 | [diff] [blame] | 37 | // CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) |
| 38 | // CHECK-NEXT: catch i8* null |
Anders Carlsson | 4bdbc0c | 2011-04-11 14:13:40 +0000 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | return 0; |
| 42 | } |
Anders Carlsson | 3a01693 | 2011-04-17 23:33:40 +0000 | [diff] [blame] | 43 | |
| 44 | } |
Bill Wendling | f7a9da0 | 2013-02-20 07:22:19 +0000 | [diff] [blame] | 45 | |
Bill Wendling | 4e1125f | 2013-02-22 09:10:20 +0000 | [diff] [blame] | 46 | // CHECK: attributes [[NR]] = { noreturn } |