Clang Project

clang_source_code/test/CodeGenCXX/sanitize-dtor-repress-aliasing.cpp
1// Test -fsanitize-memory-use-after-dtor
2// RUN: %clang_cc1 -fsanitize=memory -O1 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
3// RUN: %clang_cc1 -fsanitize=memory -O2 -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
4
5template <class T>
6class Vector {
7public:
8  int size;
9  ~Vector() {}
10};
11
12// Virtual function table for the derived class only contains
13// its own destructors, with no aliasing to base class dtors.
14struct Base {
15  Vector<int> v;
16  int x;
17  Base() { x = 5; }
18  virtual ~Base() {}
19};
20
21struct Derived : public Base {
22  int z;
23  Derived() { z = 10; }
24  ~Derived() {}
25};
26
27Derived d;
28
29// Definition of virtual function table
30// CHECK: @_ZTV7Derived = {{.*}}@_ZN7DerivedD1Ev{{.*}}@_ZN7DerivedD0Ev
31