llvm-project
27 строк · 924.0 Байт
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[]) {10uint64_t a = 10;11uint64_t b = 20;12dfsan_set_label(8, &a, sizeof(a));13uint64_t c = foo(a, b);14for (int i = 0; i < argc; ++i)15c += foo(c, b);16dfsan_print_origin_trace(&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