Revert "[lldb][test] Remove compiler version check and use regex" (#124101)
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / memset-recover.cpp
blob093a0179347befd837af1b6f46e79b382c7b10c2
1 // RUN: %clangxx_hwasan %s -o %t
2 // RUN: %env_hwasan_opts=halt_on_error=0 not %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST --check-prefixes=CHECK,RECOVER
3 // RUN: %env_hwasan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST
5 #include <sanitizer/hwasan_interface.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
11 __attribute__((no_sanitize("hwaddress"))) void
12 ForceCallInterceptor(void *p, int c, size_t size) {
13 memset(p, c, size) == nullptr;
16 int main(int argc, char **argv) {
17 __hwasan_enable_allocator_tagging();
18 char a[] = {static_cast<char>(argc), 2, 3, 4};
19 int size = sizeof(a);
20 char *volatile p = (char *)malloc(size);
21 void *volatile p2 = p;
22 for (int i = 0; p2 == p; p2 = __hwasan_tag_pointer(p, ++i)) {
24 ForceCallInterceptor(p2, 0, size);
25 free(p);
26 fprintf(stderr, "RETURN_FROM_TEST\n");
27 return 0;
28 // CHECK: HWAddressSanitizer: tag-mismatch on address
29 // CHECK: WRITE of size 4
30 // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main {{.*}}memset-recover.cpp:[[@LINE-28]]
31 // RECOVER: RETURN_FROM_TEST