about summary refs log tree commit diff homepage
path: root/test/Feature/EscapingFunctionsAlias.c
blob: f5e0fb11afd15b28d94481be0b380c90bf5e695b (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
38
39
40
41
42
43
44
45
46
47
48
49
// Darwin does not support strong aliases.
// REQUIRES: not-darwin
// RUN: %llvmgcc -emit-llvm %O0opt -g -c %s -o %t.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee -debug-print-escaping-functions --output-dir=%t.klee-out %t.bc 2> %t.log
// RUN: FileCheck --input-file=%t.log %s

#include <stdint.h>

void global_alias(void) __attribute__((alias("global_aliasee")));
void global_aliasee(void) {
    return;
}

uint8_t bitcast_of_alias(void) __attribute__((alias("bitcast_of_global_alias")));
uint8_t bitcast_of_global_alias(void) {
    return 1;
}

uint8_t bitcast_of_aliasee(void) __attribute__((alias("bitcast_of_global_aliasee")));
uint8_t bitcast_of_global_aliasee(void) {
    return 1;
}

uint64_t bitcast_in_global_alias(void) __attribute__((alias("bitcast_in_alias")));
uint8_t bitcast_in_alias(void) {
    return 1;
}

int main(int argc, char *argv[]) {
    global_aliasee();
    global_alias();

    // casting alias
    // should result in aliasee being marked as escaping
    uint64_t (*f1)(void) =(uint64_t (*)(void))bitcast_of_alias;
    f1();

    // casting aliasee
    uint64_t (*f2)(void) =(uint64_t (*)(void))bitcast_of_global_aliasee;
    f2();

    bitcast_in_alias();
    // cast when aliasing should not result in either function being marked as escaping
    bitcast_in_global_alias();

    // CHECK: KLEE: escaping functions: {{\[((bitcast_of_global_alias|bitcast_of_global_aliasee)(, )?){2}\]}}
    return 0;
}