1// RUN: %clangxx_nsan -O2 %s -o %t
2// RUN: %run %t 2>&1 | FileCheck %s
3
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 delimiters
12 char input[] = "apple,banana,cherry,date";
13 char *token;
14 char *rest = input; // Pointer to keep track of the rest of the string
15
16 // Tokenize the string using strsep
17 while ((token = strsep(&rest, ",")) != NULL) {
18 std::cout << token << std::endl;
19 }
20
21 __nsan_dump_shadow_mem(addr: &input[5], size_bytes: 1, bytes_per_line: 1, reserved: 0);
22 // CHECK: 0x{{[a-f0-9]*}}: _
23 return 0;
24}
25

source code of compiler-rt/test/nsan/intercep_strsep.cpp