1// RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t
2// RUN: %clangxx_asan -O3 -mllvm -asan-instrument-dynamic-allocas %s -o %t
3// RUN: %run %t 2>&1
4//
5// MSVC does not support asan-instrument-dynamic-allocas yet
6// UNSUPPORTED: msvc
7
8#include "sanitizer/asan_interface.h"
9#include <assert.h>
10#include <stdint.h>
11
12__attribute__((noinline)) void foo(int index, int len) {
13 volatile char str[len] __attribute__((aligned(32)));
14 assert(!(reinterpret_cast<uintptr_t>(str) & 31L));
15 char *q = (char *)__asan_region_is_poisoned(beg: (char *)str, size: 64);
16 assert(q && ((q - str) == index));
17}
18
19int main(int argc, char **argv) {
20 for (int i = 1; i < 33; ++i)
21 foo(index: i, len: i);
22
23 for (int i = 1; i < 33; ++i)
24 foo(index: i, len: i);
25
26 return 0;
27}
28

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of compiler-rt/test/asan/TestCases/alloca_instruments_all_paddings.cpp