brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 74de0c3 Raw
43 lines · cpp
1// RUN: %clangxx_msan -fsanitize-recover=memory -mllvm -msan-instrumentation-with-call-threshold=0 -g %s -o %t \2// RUN:   && not env MSAN_OPTIONS=verbosity=1 %run %t 2>&1 | FileCheck %s3 4// REQUIRES: x86_64-target-arch5// 'long double' implementation varies between platforms.6 7#include <ctype.h>8#include <stdio.h>9 10#include <sanitizer/msan_interface.h>11 12int main(int argc, char *argv[]) {13  long double a;14  printf("a: %Lf\n", a);15  // CHECK: Shadow value (16 bytes): ffffffff ffffffff ffff0000 0000000016 17  unsigned long long b;18  printf("b: %llu\n", b);19  // CHECK: Shadow value (8 bytes): ffffffff ffffffff20 21  char *p = (char *)(&b);22  p[2] = 36;23  printf("b: %lld\n", b);24  // CHECK: Shadow value (8 bytes): ffff00ff ffffffff25 26  b = b << 8;27  printf("b: %lld\n", b);28  __msan_print_shadow(&b, sizeof(b));29  // CHECK: Shadow value (8 bytes): 00ffff00 ffffffff30 31  unsigned int c;32  printf("c: %u\n", c);33  // CHECK: Shadow value (4 bytes): ffffffff34 35  // Converted to boolean36  if (c) {37    // CHECK: Shadow value (1 byte): 0138    printf("Hello\n");39  }40 41  return 0;42}43