Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / dtor-trivial.cpp
blob225a18c055071743ab8795c3f172534863ef455f
1 // RUN: %clangxx_msan %s -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
3 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
5 // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && %run %t >%t.out 2>&1
7 // TODO Success pending on resolution of
8 // https://github.com/google/sanitizers/issues/596
10 // XFAIL: *
12 #include <assert.h>
13 #include <sanitizer/msan_interface.h>
15 template <class T> class Vector {
16 public:
17 int size;
18 ~Vector() {}
21 struct NonTrivial {
22 int a;
23 Vector<int> v;
26 struct Trivial {
27 int a;
28 int b;
31 int main() {
32 NonTrivial *nt = new NonTrivial();
33 nt->~NonTrivial();
34 assert(__msan_test_shadow(nt, sizeof(*nt)) != -1);
36 Trivial *t = new Trivial();
37 t->~Trivial();
38 assert(__msan_test_shadow(t, sizeof(*t)) != -1);
40 return 0;