1 // RUN: %clangxx_msan %s -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-UAD
2 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-UAD
3 // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-UAD
4 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -fsanitize-memory-track-origins -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-UAD,CHECK-ORIGINS
5 // RUN: %clangxx_msan %s -fno-sanitize-memory-use-after-dtor -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-UAD-OFF
7 #include <sanitizer/msan_interface.h>
24 assert(sizeof(Simple
) <= sizeof(buf
));
26 Simple
*s
= new(&buf
) Simple();
29 fprintf(stderr
, "\n"); // Need output to parse for CHECK-UAD-OFF case
32 // CHECK-UAD: WARNING: MemorySanitizer: use-of-uninitialized-value
33 // CHECK-UAD: {{#0 0x.* in main.*use-after-dtor.cpp:}}[[@LINE-3]]
35 // CHECK-ORIGINS: Member fields were destroyed
36 // CHECK-ORIGINS: {{#0 0x.* in __sanitizer_dtor_callback}}
37 // CHECK-ORIGINS: {{#1 0x.* in .*~Simple.*cpp:}}[[@LINE-24]]:
38 // CHECK-ORIGINS: {{#2 0x.* in .*~Simple.*cpp:}}[[@LINE-19]]:
40 // CHECK-UAD: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*main}}
41 // CHECK-UAD-OFF-NOT: SUMMARY: MemorySanitizer: use-of-uninitialized-value