[PATCH] D11727: Dtor callback emitted when msan attribute not repressed for this function.
Naomi Musgrave
nmusgrave at google.com
Mon Aug 3 13:44:16 PDT 2015
nmusgrave updated this revision to Diff 31263.
nmusgrave added a comment.
- refactored test into new file, revised how function attribute examined
http://reviews.llvm.org/D11727
Files:
lib/CodeGen/CGClass.cpp
test/CodeGenCXX/sanitize-dtor-callback.cpp
test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
Index: test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
@@ -0,0 +1,19 @@
+// 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
+
+struct No_San {
+ int x;
+ No_San() {
+ x = 5;
+ }
+ __attribute__((no_sanitize_memory)) ~No_San() {}
+};
+No_San ns;
+// Repressing the sanitization attribute results in no msan
+// instrumentation of the destructor
+// CHECK: define {{.*}}No_SanD1Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]
+// CHECK-NOT: call void @__sanitizer_dtor_callback
+// CHECK: ret void
+
+// When attribute is repressed, the destructor does not emit any tail calls
+// CHECK-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory
Index: test/CodeGenCXX/sanitize-dtor-callback.cpp
===================================================================
--- test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -67,3 +67,6 @@
// CHECK: call void @__sanitizer_dtor_callback
// CHECK-NOT: call void @__sanitizer_dtor_callback
// CHECK: ret void
+
+// When attribute is repressed, the destructor does not emit any tail calls
+// CHECK-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory
Index: lib/CodeGen/CGClass.cpp
===================================================================
--- lib/CodeGen/CGClass.cpp
+++ lib/CodeGen/CGClass.cpp
@@ -1479,7 +1479,8 @@
ExitCXXTryStmt(*cast<CXXTryStmt>(Body), true);
// Insert memory-poisoning instrumentation.
- if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor)
+ if (CGM.getCodeGenOpts().SanitizeMemoryUseAfterDtor
+ && SanOpts.has(SanitizerKind::Memory))
EmitDtorSanitizerCallback(*this, Dtor);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11727.31263.patch
Type: text/x-patch
Size: 1871 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150803/13b4c879/attachment.bin>
More information about the cfe-commits
mailing list