1// RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \
2// RUN: %run %t >%t.out 2>&1
3// RUN: FileCheck %s < %t.out
4
5#include <sanitizer/dfsan_interface.h>
6
7__attribute__((noinline)) uint64_t foo(uint64_t x, uint64_t y) { return x + y; }
8
9int main(int argc, char *argv[]) {
10 uint64_t a = 10;
11 uint64_t b = 20;
12 dfsan_set_label(label: 8, addr: &a, size: sizeof(a));
13 uint64_t c = foo(x: a, y: b);
14 for (int i = 0; i < argc; ++i)
15 c += foo(x: c, y: b);
16 dfsan_print_origin_trace(addr: &c, NULL);
17}
18
19// CHECK: Taint value 0x8 {{.*}} origin tracking ()
20// CHECK: Origin value: {{.*}}, Taint value was stored to memory at
21// CHECK: #0 {{.*}} in main {{.*}}origin_branch.c:[[@LINE-6]]
22
23// CHECK: Origin value: {{.*}}, Taint value was stored to memory at
24// CHECK: #0 {{.*}} in main {{.*}}origin_branch.c:[[@LINE-11]]
25
26// CHECK: Origin value: {{.*}}, Taint value was created at
27// CHECK: #0 {{.*}} in main {{.*}}origin_branch.c:[[@LINE-15]]
28

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