llvm-cov: Changed XFAIL targets to be more generic.
[oota-llvm.git] / test / tools / llvm-cov / Inputs / test.cpp
1 #include <cstdlib>
2
3 bool on = false;
4 int len = 42;
5 double grid[10][10] = {0};
6 const char * hello = "world";
7 const char * world = "hello";
8
9 struct A {
10   virtual void B();
11 };
12
13 void A::B() {}
14
15 void useless() {}
16
17 double more_useless() {
18   return 0;
19 }
20
21 int foo() {
22   on = true;
23   return 3;
24 }
25
26 int bar() {
27   len--;
28   return foo() + 45;
29 }
30
31 void assign(int ii, int jj) {
32   grid[ii][jj] = (ii+1) * (jj+1);
33 }
34
35 void initialize_grid() {
36   for (int ii = 0; ii < 2; ii++)
37     for (int jj = 0; jj < 2; jj++)
38       assign(ii, jj);
39 }
40
41 int main() {
42   initialize_grid();
43
44   int a = 2;
45   on = rand() % 2;
46   if (on) {
47     foo();
48     ++a;
49   } else {
50     bar();
51     a += rand();
52   }
53
54   for (int ii = 0; ii < 10; ++ii) {
55     switch (rand() % 5) {
56       case 0:
57         a += rand();
58         break;
59       case 1:
60       case 2:
61         a += rand() / rand();
62         break;
63       case 3:
64         a -= rand();
65         break;
66       default:
67         a = -1;
68     }
69   }
70
71   A thing;
72   for (uint64_t ii = 0; ii < 4294967296; ++ii)
73     thing.B();
74
75   return a + 8 + grid[2][3] + len;
76   return more_useless();
77 }