brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · b855237 Raw
34 lines · cpp
1// RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&12// RUN: FileCheck %s < %t.out3// RUN: %clangxx_msan -O1 %s -o %t && not %run %t >%t.out 2>&14// RUN: FileCheck %s < %t.out5// RUN: %clangxx_msan -O2 %s -o %t && not %run %t >%t.out 2>&16// RUN: FileCheck %s < %t.out7// RUN: %clangxx_msan -O3 %s -o %t && not %run %t >%t.out 2>&18// RUN: FileCheck %s < %t.out9 10// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %run %t >%t.out 2>&111// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out12// RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %run %t >%t.out 2>&113// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out14// RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %run %t >%t.out 2>&115// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out16// RUN: %clangxx_msan -fsanitize-memory-track-origins -O3 %s -o %t && not %run %t >%t.out 2>&117// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out18 19#include <sanitizer/msan_interface.h>20#include <stdlib.h>21 22int main(int argc, char **argv) {23  int *volatile p = (int *)malloc(sizeof(int));24 25  __msan_check_mem_is_initialized(p, sizeof(*p));26  // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value27  // CHECK: {{#0 0x.* in main .*check_mem_is_initialized.cpp:}}[[@LINE-2]]28 29  // CHECK-ORIGINS: Uninitialized value was created by a heap allocation30  // CHECK-ORIGINS: {{#0 0x.* in .*malloc}}31  // CHECK-ORIGINS: {{#1 0x.* in main .*check_mem_is_initialized.cpp:}}[[@LINE-8]]32  return 0;33}34