llvm-project
25 строк · 556.0 Байт
1// RUN: %clang_dfsan %s -o %t
2// RUN: %run %t
3//
4#include <sanitizer/dfsan_interface.h>5
6#include <assert.h>7#include <stdio.h>8#include <string.h>9
10int foo(int a, int b) {11return a + b;12}
13
14int main(int argc, char *argv[]) {15int a = 10;16int b = 20;17dfsan_set_label(8, &a, sizeof(a));18dfsan_set_label(128, &b, sizeof(b));19int c = foo(a, b);20printf("A: 0x%x\n", dfsan_get_label(a));21printf("B: 0x%x\n", dfsan_get_label(b));22dfsan_label l = dfsan_get_label(c);23printf("C: 0x%x\n", l);24assert(l == 136); // OR of the other two labels.25}
26