llvm-project
30 строк · 662.0 Байт
1// RUN: %clang_dfsan %s -fsanitize-ignorelist=%S/Inputs/flags_abilist.txt -DFORCE_ZERO_LABELS -o %t && %run %t
2// RUN: %clang_dfsan %s -o %t && %run %t
3
4#include <sanitizer/dfsan_interface.h>5
6#include <assert.h>7
8int function_to_force_zero(int i, int* out) {9*out = i;10return i;11}
12
13int main(void) {14int i = 1;15dfsan_label i_label = 2;16dfsan_set_label(i_label, &i, sizeof(i));17
18int out = 0;19int ret = function_to_force_zero(i, &out);20
21#ifdef FORCE_ZERO_LABELS22assert(dfsan_get_label(out) == 0);23assert(dfsan_get_label(ret) == 0);24#else25assert(dfsan_get_label(out) == i_label);26assert(dfsan_get_label(ret) == i_label);27#endif28
29return 0;30}
31