1 | // Test -fsanitize-memory-use-after-dtor |
2 | // RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s |
3 | |
4 | // The no_sanitize_memory attribute, when applied to a destructor, |
5 | // represses emission of sanitizing callback |
6 | |
7 | template <class T> class Vector { |
8 | public: |
9 | int size; |
10 | ~Vector() {} |
11 | }; |
12 | |
13 | struct No_San { |
14 | Vector<int> v; |
15 | int x; |
16 | No_San() { } |
17 | __attribute__((no_sanitize_memory)) ~No_San() = default; |
18 | }; |
19 | |
20 | int main() { |
21 | No_San *ns = new No_San(); |
22 | ns->~No_San(); |
23 | return 0; |
24 | } |
25 | |
26 | // Repressing the sanitization attribute results in no msan |
27 | // instrumentation of the destructor |
28 | // CHECK: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]] |
29 | // CHECK-NOT: call void {{.*}}sanitizer_dtor_callback |
30 | // CHECK: ret void |
31 | |
32 | // CHECK: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]] |
33 | // CHECK-NOT: call void {{.*}}sanitizer_dtor_callback |
34 | // CHECK: call void {{.*}}VectorIiED2Ev |
35 | // CHECK-NOT: call void {{.*}}sanitizer_dtor_callback |
36 | // CHECK: ret void |
37 | |
38 | // CHECK: define {{.*}}VectorIiED2Ev |
39 | // CHECK: call void {{.*}}sanitizer_dtor_callback |
40 | // CHECK: ret void |
41 | |
42 | // When attribute is repressed, the destructor does not emit any tail calls |
43 | // CHECK-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory |
44 | |