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 // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 -mllvm -dfsan-instrument-with-call-threshold=0 %s -o %t && \
6 // RUN:     %run %t >%t.out 2>&1
7 // RUN: FileCheck %s < %t.out
8 //
9 // REQUIRES: x86_64-target-arch
10 
11 #include <sanitizer/dfsan_interface.h>
12 
foo(uint64_t a,uint64_t b)13 __attribute__((noinline)) uint64_t foo(uint64_t a, uint64_t b) { return a + b; }
14 
main(int argc,char * argv[])15 int main(int argc, char *argv[]) {
16   uint64_t a = 10;
17   uint64_t b = 20;
18   dfsan_set_label(8, &a, sizeof(a));
19   uint64_t c = foo(a, b);
20   dfsan_print_origin_trace(&c, NULL);
21   dfsan_print_origin_trace((int*)(&c) + 1, NULL);
22 }
23 
24 // CHECK: Taint value 0x8 {{.*}} origin tracking ()
25 // CHECK: Origin value: {{.*}}, Taint value was stored to memory at
26 // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-7]]
27 
28 // CHECK: Origin value: {{.*}}, Taint value was created at
29 // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-11]]
30 
31 // CHECK: Taint value 0x8 {{.*}} origin tracking ()
32 // CHECK: Origin value: {{.*}}, Taint value was stored to memory at
33 // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-14]]
34 
35 // CHECK: Origin value: {{.*}}, Taint value was created at
36 // CHECK: #0 {{.*}} in main {{.*}}origin_set_label.c:[[@LINE-18]]
37