Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / sanitize-dtor-fn-attribute.cpp
blob61acea458d4a6d2927ce82b343a9bc427cf41507
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_"
4 // The no_sanitize_memory attribute, when applied to a destructor,
5 // represses emission of sanitizing callback
7 template <class T> class Vector {
8 public:
9 int size;
10 ~Vector() {}
13 struct No_San {
14 Vector<int> v;
15 int x;
16 No_San() { }
17 __attribute__((no_sanitize_memory)) ~No_San() = default;
20 int main() {
21 No_San *ns = new No_San();
22 ns->~No_San();
23 return 0;
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
31 // CHECK: define {{.*}}No_SanD2Ev{{.*}} [[ATTRIBUTE:#[0-9]+]]
32 // CHECK: call void {{.*}}VectorIiED2Ev
33 // CHECK: ret void
35 // CHECK: define {{.*}}VectorIiED2Ev
36 // CHECK: call void @__sanitizer_dtor_callback
37 // CHECK: ret void
39 // When attribute is repressed, the destructor does not emit any tail calls
40 // CHECK-NOT: attributes [[ATTRIBUTE]] = {{.*}} sanitize_memory