diff options
| author | Naomi Musgrave <nmusgrave@google.com> | 2015-08-03 22:53:11 +0000 |
|---|---|---|
| committer | Naomi Musgrave <nmusgrave@google.com> | 2015-08-03 22:53:11 +0000 |
| commit | bb4df94faa8cb027fb76d17ff7145f98700bac0a (patch) | |
| tree | a32021f81a6b93eea218067410b1231139b2778b /clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp | |
| parent | 45291391b281283ac36ed7415cfaee54db4e2e17 (diff) | |
| download | bcm5719-llvm-bb4df94faa8cb027fb76d17ff7145f98700bac0a.tar.gz bcm5719-llvm-bb4df94faa8cb027fb76d17ff7145f98700bac0a.zip | |
Dtor callback emitted when msan attribute not repressed for this function.
Summary: In addition to checking compiler flags, the front-end also examines the attributes of the destructor definition to ensure that the SanitizeMemory attribute is attached.
Reviewers: eugenis, kcc
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D11727
refactored test into new file, revised how function attribute examined
modified test to examine default dtor with and without attribute
removed attribute check
llvm-svn: 243912
Diffstat (limited to 'clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp')
| -rw-r--r-- | clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp b/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp new file mode 100644 index 00000000000..8a9e477cf1b --- /dev/null +++ b/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp @@ -0,0 +1,51 @@ +// Test -fsanitize-memory-use-after-dtor +// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -DATTRIBUTE -fsanitize=memory -fsanitize-memory-use-after-dtor -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-ATTR + +template <class T> class Vector { + public: + ~Vector() {} +}; + +struct No_San { + Vector<int> v; + No_San() { } +#ifdef ATTRIBUTE + __attribute__((no_sanitize_memory)) ~No_San() = default; +#else + ~No_San() = default; +#endif +}; + +int main() { + No_San *ns = new No_San(); + ns->~No_San(); + return 0; +} + +// Repressing the sanitization attribute results in no msan +// instrumentation of the destructor +// CHECK: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]] +// CHECK: call void {{.*}}No_SanD2Ev +// CHECK: call void @__sanitizer_dtor_callback +// CHECK: ret void + +// CHECK-ATTR: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]] +// CHECK-ATTR: call void {{.*}}No_SanD2Ev +// CHECK-ATTR-NOT: call void @__sanitizer_dtor_callback +// CHECK-ATTR: ret void + + +// CHECK: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]] +// CHECK: call void {{.*}}Vector +// CHECK: call void @__sanitizer_dtor_callback +// CHECK: ret void + +// CHECK-ATTR: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]] +// CHECK-ATTR: call void {{.*}}Vector +// CHECK-ATTR-NOT: call void @__sanitizer_dtor_callback +// CHECK-ATTR: ret void + +// When attribute is repressed, the destructor does not emit any tail calls +// CHECK: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory +// CHECK-ATTR-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory |

