1// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s
2#include <typeinfo>
3
4namespace Test1 {
5
6// PR7400
7struct A { virtual void f(); };
8
9// CHECK: @_ZN5Test16int_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIi to %"class.std::type_info"*), align 8
10const 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
13const std::type_info &A_ti = typeid(const volatile A &);
14
15volatile char c;
16
17// CHECK: @_ZN5Test14c_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTIc to %"class.std::type_info"*), align 8
18const std::type_info &c_ti = typeid(c);
19
20extern const double &d;
21
22// CHECK: @_ZN5Test14d_tiE = constant %"class.std::type_info"* bitcast (i8** @_ZTId to %"class.std::type_info"*), align 8
23const std::type_info &d_ti = typeid(d);
24
25extern A &a;
26
27// CHECK: @_ZN5Test14a_tiE = global
28const std::type_info &a_ti = typeid(a);
29
30// CHECK: @_ZN5Test18A10_c_tiE = constant %"class.std::type_info"* bitcast ({ i8*, i8* }* @_ZTIA10_c to %"class.std::type_info"*), align 8
31const std::type_info &A10_c_ti = typeid(char const[10]);
32
33// CHECK-LABEL: define i8* @_ZN5Test11fEv
34const char *f() {
35  try {
36    // CHECK: br i1
37    // CHECK: invoke void @__cxa_bad_typeid() [[NR:#[0-9]+]]
38    return typeid(*static_cast<A *>(0)).name();
39  } catch (...) {
40    // CHECK:      landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
41    // CHECK-NEXT:   catch i8* null
42  }
43
44  return 0;
45}
46
47}
48
49// CHECK: attributes [[NR]] = { noreturn }
50