41 lines · cpp
1// Test -fsanitize-memory-use-after-dtor2// 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 callback6 7template <class T> class Vector {8 public:9 int size;10 ~Vector() {}11};12 13struct No_San {14 Vector<int> v;15 int x;16 No_San() { }17 __attribute__((no_sanitize_memory)) ~No_San() = default;18};19 20int 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 msan27// instrumentation of the destructor28// CHECK: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]29// CHECK: ret void30 31// CHECK: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]32// CHECK: call void {{.*}}VectorIiED2Ev33// CHECK: ret void34 35// CHECK: define {{.*}}VectorIiED2Ev36// CHECK: call void @__sanitizer_dtor_callback37// CHECK: ret void38 39// When attribute is repressed, the destructor does not emit any tail calls40// CHECK-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory41