brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · c12ae65 Raw
61 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions -fms-extensions -x c++ -Wno-implicit-function-declaration -emit-llvm %s -o - | FileCheck %s2 3// CHECK: invoke void @llvm.seh.scope.begin()4// CHECK: invoke void @llvm.seh.scope.begin()5// CHECK: invoke void @llvm.seh.scope.begin()6// CHECK: invoke void @llvm.seh.scope.end()7// CHECK: invoke void @llvm.seh.scope.end()8// CHECK: invoke void @llvm.seh.scope.end()9 10// CHECK: invoke void @llvm.seh.try.begin()11// CHECK: %[[src:[0-9-]+]] = load volatile i32, ptr %i12// CHECK-NEXT: invoke void @"?crash@@YAXH@Z"(i32 noundef %[[src]])13// CHECK: invoke void @llvm.seh.try.end()14 15// ****************************************************************************16// Abstract:     Test CPP unwind Dtoring under SEH -EHa option17 18void printf(...);19int volatile *NullPtr = 0;20void crash(int i) {21  struct A {22    ~A() {23      printf(" in A dtor \n");24    }25  } ObjA;26  if (i == 0)27    *NullPtr = 0;28 29  struct B {30    ~B() {31      printf(" in B dtor \n");32    }33  } ObjB;34  if (i == 1)35    *NullPtr = 0;36 37  struct C {38    ~C() {39      printf(" in C dtor \n");40    }41  } ObjC;42  if (i == 2)43    *NullPtr = 0;44}45 46#define TRY __try47#define CATCH_ALL __except (1)48 49int g;50int main() {51  for (int i = 0; i < 3; i++) {52    TRY {53      crash(i);54    }55    CATCH_ALL {56      printf(" Test CPP unwind: in catch handler i = %d \n", i);57    }58  }59  return 0;60}61