1 // RUN: %clangxx_msan %s -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1
2 // RUN: FileCheck %s --check-prefix=CHECK-UAD < %t.out
4 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1
5 // RUN: FileCheck %s --check-prefix=CHECK-UAD < %t.out
7 // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1
8 // RUN: FileCheck %s --check-prefix=CHECK-UAD < %t.out
10 // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -fsanitize-memory-track-origins -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1
11 // RUN: FileCheck %s --check-prefixes=CHECK-UAD,CHECK-ORIGINS < %t.out
13 // RUN: %clangxx_msan %s -fno-sanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t > %t.out 2>&1
14 // RUN: FileCheck %s --check-prefix=CHECK-UAD-OFF < %t.out
16 #include <sanitizer/msan_interface.h>
33 assert(sizeof(Simple
) <= sizeof(buf
));
35 Simple
*s
= new(&buf
) Simple();
38 fprintf(stderr
, "\n"); // Need output to parse for CHECK-UAD-OFF case
41 // CHECK-UAD: WARNING: MemorySanitizer: use-of-uninitialized-value
42 // CHECK-UAD: {{#0 0x.* in main.*use-after-dtor.cpp:}}[[@LINE-3]]
44 // CHECK-ORIGINS: Memory was marked as uninitialized
45 // CHECK-ORIGINS: {{#0 0x.* in __sanitizer_dtor_callback}}
46 // CHECK-ORIGINS: {{#1 0x.* in Simple::~Simple}}
48 // CHECK-UAD: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*main}}
49 // CHECK-UAD-OFF-NOT: SUMMARY: MemorySanitizer: use-of-uninitialized-value