about summary refs log tree commit diff homepage
path: root/test/Feature/AliasFunction.c
blob: 019ebe6740362efc16c79d80bd8f8515c3b2c91b (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: %llvmgcc %s -emit-llvm -O0 -c -o %t1.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out %t1.bc > %t1.log
// RUN: grep -c foo %t1.log | grep 5
// RUN: grep -c bar %t1.log | grep 4

#include <stdio.h>
#include <stdlib.h>

void __attribute__ ((noinline)) foo() { printf("  foo()\n"); }
void __attribute__ ((noinline)) bar() { printf("  bar()\n"); }

int main() {
  int x;
  klee_make_symbolic(&x, sizeof(x), "x");

  // call once, so that it is not removed by optimizations
  bar();

  // no aliases
  foo();

  if (x > 10)
  {
    // foo -> bar
    klee_alias_function("foo", "bar");

    if (x > 20)
      foo();
  }
  
  foo();

  // undo
  klee_alias_function("foo", "foo");
  foo();
}