| 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 --implicit-check-not="call void @__sanitizer_" |
| 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: ret void |
| 30 |
|
| 31 |
// CHECK: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]] |
| 32 |
// CHECK: call void {{.*}}VectorIiED2Ev |
| 33 |
// CHECK: ret void |
| 34 |
|
| 35 |
// CHECK: define {{.*}}VectorIiED2Ev |
| 36 |
// CHECK: call void @__sanitizer_dtor_callback |
| 37 |
// CHECK: ret void |
| 38 |
|
| 39 |
// When attribute is repressed, the destructor does not emit any tail calls |
| 40 |
// CHECK-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory |