Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
      2 // RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -disable-llvm-optzns -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
      3 
      4 class A {
      5  public:
      6   int x;
      7   A() {}
      8   virtual ~A() {}
      9 };
     10 A a;
     11 
     12 class B : virtual public A {
     13  public:
     14   int y;
     15   B() {}
     16   ~B() {}
     17 };
     18 B b;
     19 
     20 // CHECK-LABEL: define {{.*}}AD1Ev
     21 // CHECK-NOT: call void @__sanitizer_dtor_callback
     22 // CHECK: call void {{.*}}AD2Ev
     23 // CHECK-NOT: call void @__sanitizer_dtor_callback
     24 // CHECK: ret void
     25 
     26 // After invoking base dtor and dtor for virtual base, poison vtable ptr.
     27 // CHECK-LABEL: define {{.*}}BD1Ev
     28 // CHECK-NOT: call void @__sanitizer_dtor_callback
     29 // CHECK: call void {{.*}}BD2Ev
     30 // CHECK-NOT: call void @__sanitizer_dtor_callback
     31 // CHECK: call void {{.*}}AD2Ev
     32 // CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
     33 // CHECK-NOT: call void @__sanitizer_dtor_callback
     34 // CHECK: ret void
     35 
     36 // Since no virtual bases, poison vtable ptr here.
     37 // CHECK-LABEL: define {{.*}}AD2Ev
     38 // CHECK: call void @__sanitizer_dtor_callback
     39 // CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8
     40 // CHECK-NOT: call void @__sanitizer_dtor_callback
     41 // CHECK: ret void
     42 
     43 // Poison members
     44 // CHECK-LABEL: define {{.*}}BD2Ev
     45 // CHECK: call void @__sanitizer_dtor_callback
     46 // CHECK-NOT: call void @__sanitizer_dtor_callback
     47 // CHECK: ret void
     48