brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 24a19cd Raw
70 lines · cpp
1// RUN: %clang_cc1 -emit-llvm -O1 -o - -triple=i386-pc-win32 %s -fexceptions -fcxx-exceptions | FileCheck %s2 3struct type_info;4namespace std { using ::type_info; }5 6struct V { virtual void f(); };7struct A : virtual V { A(); };8 9extern A a;10extern V v;11extern int b;12A* fn();13 14const std::type_info* test0_typeid() { return &typeid(int); }15// CHECK-LABEL: define dso_local noundef nonnull ptr @"?test0_typeid@@YAPBUtype_info@@XZ"()16// CHECK:   ret ptr @"??_R0H@8"17 18const std::type_info* test1_typeid() { return &typeid(A); }19// CHECK-LABEL: define dso_local noundef nonnull ptr @"?test1_typeid@@YAPBUtype_info@@XZ"()20// CHECK:   ret ptr @"??_R0?AUA@@@8"21 22const std::type_info* test2_typeid() { return &typeid(&a); }23// CHECK-LABEL: define dso_local noundef nonnull ptr @"?test2_typeid@@YAPBUtype_info@@XZ"()24// CHECK:   ret ptr @"??_R0PAUA@@@8"25 26const std::type_info* test3_typeid() { return &typeid(*fn()); }27// CHECK-LABEL: define dso_local noundef ptr @"?test3_typeid@@YAPBUtype_info@@XZ"()28// CHECK:        [[CALL:%.*]] = tail call noundef ptr @"?fn@@YAPAUA@@XZ"()29// CHECK-NEXT:   [[CMP:%.*]] = icmp eq ptr [[CALL]], null30// CHECK-NEXT:   br i1 [[CMP]]31// CHECK:        call ptr @__RTtypeid(ptr null)32// CHECK-NEXT:   unreachable33// CHECK:        [[VBTBL:%.*]] = load ptr, ptr [[CALL]], align 434// CHECK-NEXT:   [[VBSLOT:%.*]] = getelementptr inbounds nuw i8, ptr [[VBTBL]], i32 435// CHECK-NEXT:   [[VBASE_OFFS:%.*]] = load i32, ptr [[VBSLOT]], align 436// CHECK-NEXT:   [[ADJ:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i32 [[VBASE_OFFS]]37// CHECK-NEXT:   [[RT:%.*]] = tail call ptr @__RTtypeid(ptr nonnull [[ADJ]])38// CHECK-NEXT:   ret ptr [[RT]]39 40const std::type_info* test4_typeid() { return &typeid(b); }41// CHECK: define dso_local noundef nonnull ptr @"?test4_typeid@@YAPBUtype_info@@XZ"()42// CHECK:   ret ptr @"??_R0H@8"43 44const std::type_info* test5_typeid() { return &typeid(v); }45// CHECK: define dso_local noundef nonnull ptr @"?test5_typeid@@YAPBUtype_info@@XZ"()46// CHECK:   ret ptr @"??_R0?AUV@@@8"47 48const std::type_info *test6_typeid() { return &typeid((V &)v); }49// CHECK: define dso_local noundef nonnull ptr @"?test6_typeid@@YAPBUtype_info@@XZ"()50// CHECK:   ret ptr @"??_R0?AUV@@@8"51 52namespace PR26329 {53struct Polymorphic {54  virtual ~Polymorphic();55};56 57void f(const Polymorphic &poly) {58  try {59    throw;60  } catch (...) {61    Polymorphic cleanup;62    typeid(poly);63  }64}65// CHECK-LABEL: define dso_local void @"?f@PR26329@@YAXABUPolymorphic@1@@Z"(66// CHECK: %[[cs:.*]] = catchswitch within none [label %{{.*}}] unwind to caller67// CHECK: %[[cp:.*]] = catchpad within %[[cs]] [ptr null, i32 64, ptr null]68// CHECK: invoke ptr @__RTtypeid(ptr {{.*}}) [ "funclet"(token %[[cp]]) ]69}70