summaryrefslogtreecommitdiff
path: root/test/tools/llvm-cov/Inputs/test.cpp
blob: 07bc3f294c502ec853131964a8189e35fa5f7ab3 (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <cstdlib>

bool on = false;
int len = 42;
double grid[10][10] = {0};
const char * hello = "world";
const char * world = "hello";

struct A {
  virtual void B();
};

void A::B() {}

void useless() {}

double more_useless() {
  return 0;
}

int foo() {
  on = true;
  return 3;
}

int bar() {
  len--;
  return foo() + 45;
}

void assign(int ii, int jj) {
  grid[ii][jj] = (ii+1) * (jj+1);
}

void initialize_grid() {
  for (int ii = 0; ii < 2; ii++)
    for (int jj = 0; jj < 2; jj++)
      assign(ii, jj);
}

int main() {
  initialize_grid();

  int a = 2;
  on = rand() % 2;
  if (on) {
    foo();
    ++a;
  } else {
    bar();
    a += rand();
  }

  for (int ii = 0; ii < 10; ++ii) {
    switch (rand() % 5) {
      case 0:
        a += rand();
        break;
      case 1:
      case 2:
        a += rand() / rand();
        break;
      case 3:
        a -= rand();
        break;
      default:
        a = -1;
    }
  }

  A thing;
  for (uint64_t ii = 0; ii < 4294967296; ++ii)
    thing.B();

  return a + 8 + grid[2][3] + len;
  return more_useless();
}