replay-without-inlining.c revision 183ff2aaacbc1995ed64d5e2ffea4456fd871633
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s
2
3typedef struct {
4    char I[4];
5    int S;
6} Hdr;
7typedef struct {
8    short w;
9} Hdr2;
10typedef struct {
11    Hdr2 usedtobeundef;
12} Info;
13typedef struct {
14    const unsigned char *ib;
15    int cur;
16    int end;
17} IB;
18inline unsigned long gl(IB *input);
19inline void gbs(IB *input, unsigned char *buf, int count);
20void getB(IB *st, Hdr2 *usedtobeundef);
21inline unsigned char gb(IB *input) {
22    if (input->cur + 1 > input->end)
23      ;
24    return input->ib[(input->cur)++];
25}
26static void getID(IB *st, char str[4]) {
27    str[0] = gb(st);
28    str[1] = gb(st);
29    str[2] = gb(st);
30    str[3] = gb(st);
31}
32static void getH(IB *st, Hdr *header) {
33    getID (st, header->I);
34    header->S = gl(st);
35}
36static void readILBM(IB *st, Info *pic) {
37    // Initialize field;
38    pic->usedtobeundef.w = 5;
39
40    // Time out in the function so that we will be forced to retry with no inlining.
41    Hdr header;
42    getH (st, &header);
43    getID(st, header.I);
44    int i = 0;
45    while (st->cur < st->end && i < 4) {
46      i++;
47      getH (st, &header);
48    }
49}
50int bitmapImageRepFromIFF(IB st, const unsigned char *ib, int il) {
51    Info pic;
52    st.ib = ib;
53    st.cur = 0;
54    st.end = il;
55    readILBM(&st,&pic);
56    return pic.usedtobeundef.w; // No undefined value warning here.
57}
58