blob: 4e32d2dcb5a527b130b92e95a58e3d837c2d3e38 [file] [log] [blame]
Richard Smith47d21452011-12-27 12:18:28 +00001// RUN: %clang_cc1 -I%S %s -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - | FileCheck %s
2#include <typeinfo>
3
4namespace Test1 {
5
6struct Item {
7 const std::type_info &ti;
8 const char *name;
9 void *(*make)();
10};
11
12template<typename T> void *make_impl() { return new T; }
13template<typename T> constexpr Item item(const char *name) {
14 return { typeid(T), name, make_impl<T> };
15}
16
17struct A { virtual ~A(); };
18struct B : virtual A {};
19struct C { int n; };
20
Richard Smith9be36ab2012-10-17 23:52:07 +000021// CHECK: @_ZN5Test1L5itemsE = internal constant [4 x {{.*}}] [{{.*}} @_ZTIN5Test11AE {{.*}}, {{.*}}, {{.*}} @_ZN5Test19make_implINS_1AEEEPvv }, {{.*}} @_ZTIN5Test11BE {{.*}} @_ZN5Test19make_implINS_1BEEEPvv {{.*}} @_ZTIN5Test11CE {{.*}} @_ZN5Test19make_implINS_1CEEEPvv {{.*}} @_ZTIi {{.*}} @_ZN5Test19make_implIiEEPvv }]
Richard Smith47d21452011-12-27 12:18:28 +000022constexpr Item items[] = {
23 item<A>("A"), item<B>("B"), item<C>("C"), item<int>("int")
24};
25
Richard Smith9be36ab2012-10-17 23:52:07 +000026// CHECK: @_ZN5Test11xE = constant %"class.std::type_info"* bitcast ({{.*}}* @_ZTIN5Test11AE to %"class.std::type_info"*), align 8
Richard Smith47d21452011-12-27 12:18:28 +000027constexpr auto &x = items[0].ti;
28
Richard Smith9be36ab2012-10-17 23:52:07 +000029// CHECK: @_ZN5Test11yE = constant %"class.std::type_info"* bitcast ({{.*}}* @_ZTIN5Test11BE to %"class.std::type_info"*), align 8
30constexpr auto &y = typeid(B{});
31
Richard Smith47d21452011-12-27 12:18:28 +000032}