Home | History | Annotate | Download | only in msan
      1 // RUN: %clangxx_msan -O0 -g %s -o %t && %run %t >%t.out 2>&1
      2 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NO-ORIGINS < %t.out
      3 
      4 // RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 -g %s -o %t && %run %t >%t.out 2>&1
      5 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ORIGINS < %t.out
      6 
      7 // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -O0 -g %s -o %t && %run %t >%t.out 2>&1
      8 // RUN: FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ORIGINS < %t.out
      9 
     10 #include <sanitizer/msan_interface.h>
     11 
     12 int main(void) {
     13   char *p = new char[16];
     14   __msan_print_shadow(p, 1);
     15   __msan_print_shadow(p+1, 1);
     16   __msan_print_shadow(p+3, 1);
     17   __msan_print_shadow(p+15, 1);
     18   __msan_print_shadow(p, 0);
     19   delete[] p;
     20   int x = 0;
     21   __msan_print_shadow(&x, 3);
     22   return 0;
     23 }
     24 
     25 // CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
     26 // CHECK-NO-ORIGINS:   0x{{.*}}: ff...... ........ ........ ........
     27 // CHECK-ORIGINS:   0x{{.*}}: ff...... ........ ........ ........  |A . . .|
     28 // CHECK-ORIGINS: Origin A (origin_id {{.*}}):
     29 
     30 // CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
     31 // CHECK-NO-ORIGINS:   0x{{.*}}: ..ff.... ........ ........ ........
     32 // CHECK-ORIGINS:   0x{{.*}}: ..ff.... ........ ........ ........  |A . . .|
     33 // CHECK-ORIGINS: Origin A (origin_id {{.*}}):
     34 
     35 // CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
     36 // CHECK-NO-ORIGINS:   0x{{.*}}: ......ff ........ ........ ........
     37 // CHECK-ORIGINS:   0x{{.*}}: ......ff ........ ........ ........  |A . . .|
     38 // CHECK-ORIGINS: Origin A (origin_id {{.*}}):
     39 
     40 // CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 1 bytes:
     41 // CHECK-NO-ORIGINS:   0x{{.*}}: ......ff ........ ........ ........
     42 // CHECK-ORIGINS:   0x{{.*}}: ......ff ........ ........ ........  |A . . .|
     43 // CHECK-ORIGINS: Origin A (origin_id {{.*}}):
     44 
     45 // CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 0 bytes:
     46 
     47 // CHECK: Shadow map of [0x{{.*}}, 0x{{.*}}), 3 bytes:
     48 // CHECK-NO-ORIGINS:   0x{{.*}}: 000000.. ........ ........ ........
     49 // CHECK-ORIGINS:   0x{{.*}}: 000000.. ........ ........ ........  |. . . .|
     50