diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2015-07-14 00:34:50 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2015-07-14 00:34:50 +0000 |
commit | d497c49ca307f5343a634dd706706db0021a518c (patch) | |
tree | d297fd54fdb3ecfe90129c62da421d37c9e61285 /test/CodeGenCXX/sanitize-dtor-callback.cpp | |
parent | 1e15318065f9293bce3b714d496455fb3aa6df53 (diff) |
Basic code generation for MSan use-after-dtor.
Under the -fsanitize-memory-use-after-dtor (disabled by default) insert
an MSan runtime library call at the end of every destructor.
Patch by Naomi Musgrave.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242097 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/sanitize-dtor-callback.cpp')
-rw-r--r-- | test/CodeGenCXX/sanitize-dtor-callback.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/CodeGenCXX/sanitize-dtor-callback.cpp b/test/CodeGenCXX/sanitize-dtor-callback.cpp new file mode 100644 index 0000000000..4912a27229 --- /dev/null +++ b/test/CodeGenCXX/sanitize-dtor-callback.cpp @@ -0,0 +1,17 @@ +// Test -fsanitize-memory-use-after-dtor +// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fsanitize=memory -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s -check-prefix=NO_DTOR_CHECK + +struct Simple { + ~Simple() {} +}; +Simple s; +// Simple internal member is poisoned by compiler-generated dtor +// CHECK-LABEL: @_ZN6SimpleD2Ev +// CHECK: call void @__sanitizer_dtor_callback +// CHECK: ret void + +// Compiling without the flag does not generate member-poisoning dtor +// NO_DTOR_CHECK-LABEL: @_ZN6SimpleD2Ev +// NO_DTOR_CHECK-NOT: call void @sanitizer_dtor_callback +// NO_DTOR_CHECK: ret void |