Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / small_memcpy_test.cpp
blobef0ac35b8a2b702d5d1e5984f9fd62956e679ef4
1 // Test that small memcpy works correctly.
3 // RUN: %clangxx_asan %s -o %t
4 // RUN: not %run %t 8 24 2>&1 | FileCheck %s --check-prefix=CHECK
5 // RUN: not %run %t 16 32 2>&1 | FileCheck %s --check-prefix=CHECK
6 // RUN: not %run %t 24 40 2>&1 | FileCheck %s --check-prefix=CHECK
7 // RUN: not %run %t 32 48 2>&1 | FileCheck %s --check-prefix=CHECK
8 // RUN: not %run %t 40 56 2>&1 | FileCheck %s --check-prefix=CHECK
9 // RUN: not %run %t 48 64 2>&1 | FileCheck %s --check-prefix=CHECK
10 // REQUIRES: shadow-scale-3
11 #include <assert.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include <stdio.h>
16 #include <sanitizer/asan_interface.h>
18 int main(int argc, char **argv) {
19 assert(argc == 3);
20 size_t poison_from = atoi(argv[1]);
21 size_t poison_to = atoi(argv[2]);
22 assert(poison_from <= poison_to);
23 char A1[64], A2[64];
24 fprintf(stderr, "%zd %zd\n", poison_from, poison_to - poison_from);
25 __asan_poison_memory_region(&A1[0] + poison_from, poison_to - poison_from);
26 memcpy(A1, A2, sizeof(A1));
27 // CHECK: AddressSanitizer: use-after-poison
28 return 0;