brintos

brintos / llvm-project-archived public Read only

0
0
Text · 835 B · e55c3ac Raw
35 lines · cpp
1// Test -fsanitize-coverage=edge,indirect-call,trace-pc2// RUN: %clangxx_asan -O0 -DTRACE_RT %s -o %t-rt.o -c3// RUN: %clangxx_asan -O0 -fsanitize-coverage=edge,trace-pc,indirect-calls %s -o %t %t-rt.o4// RUN: %run %t5// XFAIL: msvc6 7#ifdef TRACE_RT8int pc_count;9void *last_callee;10extern "C" void __sanitizer_cov_trace_pc() {11  pc_count++;12}13extern "C" void __sanitizer_cov_trace_pc_indir(void *callee) {14  last_callee = callee;15}16#else17#  include "defines.h"18#  include <assert.h>19#  include <stdio.h>20extern int pc_count;21extern void *last_callee;22 23ATTRIBUTE_NOINLINE void foo() { printf("foo\n"); }24ATTRIBUTE_NOINLINE void bar() { printf("bar\n"); }25 26int main(int argc, char **argv) {27  void (*f)(void) = argc ? foo : bar;28  int c1 = pc_count;29  f();30  int c2 = pc_count;31  assert(c1 < c2);32  assert(last_callee == foo);33}34#endif35