about summary refs log tree commit diff homepage
path: root/test/ArrayOpt/test_update_list_order.c
blob: 979a5697a6d580c42d7840bb9b581d70941ceba1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// RUN: %clang %s -emit-llvm %O0opt -c -o %t.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --optimize-array=value --use-query-log=all:kquery --write-kqueries --output-dir=%t.klee-out %t.bc > %t.log 2>&1
// RUN: FileCheck %s -input-file=%t.log

// CHECK-DAG: KLEE: WARNING: OPT_V: successful

#include "klee/klee.h"
#include <assert.h>
#include <stdio.h>

char array[5] = {1, 2, 3, 4, 5};

int main() {
  char idx;
  char updateListBreaker;
  klee_make_symbolic(&updateListBreaker, sizeof(updateListBreaker), "ulBreak");
  klee_make_symbolic(&idx, sizeof(idx), "idx");
  klee_assume(idx < 5);
  klee_assume(idx > 0);
  klee_assume(updateListBreaker != 3);
  array[0] = updateListBreaker;
  array[2] = 6;
  updateListBreaker = array[idx];
  array[2] = 3;
  assert(updateListBreaker != 3 && "keep updateListBreak alive");

  // CHECK-DAG: KLEE: done: completed paths = 2
  // CHECK-DAG: No
  // CHECK-DAG: Yes
  if (array[idx] == 3)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}