Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / z3 / Inputs / MockZ3_solver_check.c
blob9c63a64ada220196923cd193e213aa8ba7832afb
1 #include <dlfcn.h>
2 #include <stdio.h>
4 #include <z3.h>
6 // Mock implementation: return UNDEF for the 5th invocation, otherwise it just
7 // returns the result of the real invocation.
8 Z3_lbool Z3_API Z3_solver_check(Z3_context c, Z3_solver s) {
9 static Z3_lbool (*OriginalFN)(Z3_context, Z3_solver);
10 if (!OriginalFN) {
11 OriginalFN = (Z3_lbool(*)(Z3_context, Z3_solver))dlsym(RTLD_NEXT,
12 "Z3_solver_check");
15 // Invoke the actual solver.
16 Z3_lbool Result = OriginalFN(c, s);
18 // Mock the 5th invocation to return UNDEF.
19 static unsigned int Counter = 0;
20 if (++Counter == 5) {
21 fprintf(stderr, "Z3_solver_check returns a mocked value: UNDEF\n");
22 return Z3_L_UNDEF;
24 fprintf(stderr, "Z3_solver_check returns the real value: %s\n",
25 (Result == Z3_L_UNDEF ? "UNDEF"
26 : ((Result == Z3_L_TRUE ? "TRUE" : "FALSE"))));
27 return Result;