brintos

brintos / llvm-project-archived public Read only

0
0
Text · 694 B · 4ae676f Raw
25 lines · cpp
1// RUN: %clangxx_nsan -O2 %s -o %t2// RUN: %run %t 2>&1 | FileCheck %s3 4#include <cstring>5#include <iostream>6 7extern "C" void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes,8                                       size_t bytes_per_line, size_t reserved);9 10int main() {11  // Define a C-style string with commas as delimiters12  char input[] = "apple,banana,cherry,date";13  char *token;14  char *rest = input; // Pointer to keep track of the rest of the string15 16  // Tokenize the string using strsep17  while ((token = strsep(&rest, ",")) != NULL) {18    std::cout << token << std::endl;19  }20 21  __nsan_dump_shadow_mem(&input[5], 1, 1, 0);22  // CHECK: 0x{{[a-f0-9]*}}:    _23  return 0;24}25