1// RUN: %clang_dfsan %s -o %t && %run %t
2//
3// Tests that labels are propagated through function calls.
4
5#include <sanitizer/dfsan_interface.h>
6#include <assert.h>
7
8int f(int x) {
9 int j = 2;
10 dfsan_label j_label = 2;
11 dfsan_set_label(label: j_label, addr: &j, size: sizeof(j));
12 return x + j;
13}
14
15int main(void) {
16 int i = 1;
17 dfsan_label i_label = 4;
18 dfsan_set_label(label: i_label, addr: &i, size: sizeof(i));
19
20 dfsan_label ij_label = dfsan_get_label(data: f(x: i));
21 assert(dfsan_has_label(ij_label, i_label));
22
23 /* Must be consistent with the one in f(). */
24 dfsan_label j_label = 2;
25 assert(dfsan_has_label(ij_label, 2));
26
27 return 0;
28}
29

source code of compiler-rt/test/dfsan/fncall.c