[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / compiler-rt / test / msan / use-after-dtor.cpp
blob7566ab728d2e1387fa77507b07a34de8514a754c
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>
17 #include <assert.h>
18 #include <stdio.h>
19 #include <new>
21 struct Simple {
22 int x_;
23 Simple() {
24 x_ = 5;
26 ~Simple() {
27 x_ += 1;
31 int main() {
32 unsigned long buf[1];
33 assert(sizeof(Simple) <= sizeof(buf));
35 Simple *s = new(&buf) Simple();
36 s->~Simple();
38 fprintf(stderr, "\n"); // Need output to parse for CHECK-UAD-OFF case
39 return s->x_;
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