aboutsummaryrefslogtreecommitdiffstats
path: root/test/tools/llvm-cov
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2014-04-23 16:57:46 -0700
committerStephen Hines <srhines@google.com>2014-04-24 15:53:16 -0700
commit36b56886974eae4f9c5ebc96befd3e7bfe5de338 (patch)
treee6cfb69fbbd937f450eeb83bfb83b9da3b01275a /test/tools/llvm-cov
parent69a8640022b04415ae9fac62f8ab090601d8f889 (diff)
downloadexternal_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.zip
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.gz
external_llvm-36b56886974eae4f9c5ebc96befd3e7bfe5de338.tar.bz2
Update to LLVM 3.5a.
Change-Id: Ifadecab779f128e62e430c2b4f6ddd84953ed617
Diffstat (limited to 'test/tools/llvm-cov')
-rw-r--r--test/tools/llvm-cov/Inputs/copy_block_helper.gcdabin0 -> 432 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/copy_block_helper.gcnobin0 -> 1140 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/test.cpp5
-rw-r--r--test/tools/llvm-cov/Inputs/test.cpp.gcov82
-rw-r--r--test/tools/llvm-cov/Inputs/test.gcdabin824 -> 904 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/test.gcnobin3112 -> 3552 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/test.h3
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a.cpp.gcov111
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a.h.gcov10
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a_-b.cpp.gcov134
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a_-b.h.gcov12
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.cpp.gcov160
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.h.gcov14
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a_-b_-u.cpp.gcov160
-rw-r--r--test/tools/llvm-cov/Inputs/test_-a_-b_-u.h.gcov14
-rw-r--r--test/tools/llvm-cov/Inputs/test_-b.output13
-rw-r--r--test/tools/llvm-cov/Inputs/test_-b_-f.output65
-rw-r--r--test/tools/llvm-cov/Inputs/test_-f.output38
-rw-r--r--test/tools/llvm-cov/Inputs/test_file_checksum_fail.gcdabin0 -> 825 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/test_func_checksum_fail.gcdabin0 -> 825 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/test_no_gcda.cpp.gcov79
-rw-r--r--test/tools/llvm-cov/Inputs/test_no_gcda.h.gcov8
-rw-r--r--test/tools/llvm-cov/Inputs/test_no_gcda.output8
-rw-r--r--test/tools/llvm-cov/Inputs/test_no_options.cpp.gcov79
-rw-r--r--test/tools/llvm-cov/Inputs/test_no_options.h.gcov8
-rw-r--r--test/tools/llvm-cov/Inputs/test_no_options.output8
-rw-r--r--test/tools/llvm-cov/Inputs/test_no_preserve_paths.output8
-rw-r--r--test/tools/llvm-cov/Inputs/test_objdir.cpp.gcov79
-rw-r--r--test/tools/llvm-cov/Inputs/test_objdir.h.gcov8
-rw-r--r--test/tools/llvm-cov/Inputs/test_paths.cpp.gcov79
-rw-r--r--test/tools/llvm-cov/Inputs/test_paths.gcdabin0 -> 904 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/test_paths.gcnobin0 -> 4476 bytes
-rw-r--r--test/tools/llvm-cov/Inputs/test_paths.h.gcov8
-rw-r--r--test/tools/llvm-cov/Inputs/test_preserve_paths.output8
-rw-r--r--test/tools/llvm-cov/Inputs/test_read_fail.gcnobin111 -> 71 bytes
-rw-r--r--test/tools/llvm-cov/copy_block_helper.m32
-rw-r--r--test/tools/llvm-cov/lit.local.cfg2
-rw-r--r--test/tools/llvm-cov/llvm-cov.test96
38 files changed, 1238 insertions, 93 deletions
diff --git a/test/tools/llvm-cov/Inputs/copy_block_helper.gcda b/test/tools/llvm-cov/Inputs/copy_block_helper.gcda
new file mode 100644
index 0000000..d7ff469
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/copy_block_helper.gcda
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/copy_block_helper.gcno b/test/tools/llvm-cov/Inputs/copy_block_helper.gcno
new file mode 100644
index 0000000..a9d1084
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/copy_block_helper.gcno
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/test.cpp b/test/tools/llvm-cov/Inputs/test.cpp
index 07bc3f2..e580e5a 100644
--- a/test/tools/llvm-cov/Inputs/test.cpp
+++ b/test/tools/llvm-cov/Inputs/test.cpp
@@ -1,3 +1,4 @@
+#include "test.h"
#include <cstdlib>
bool on = false;
@@ -6,10 +7,6 @@ double grid[10][10] = {0};
const char * hello = "world";
const char * world = "hello";
-struct A {
- virtual void B();
-};
-
void A::B() {}
void useless() {}
diff --git a/test/tools/llvm-cov/Inputs/test.cpp.gcov b/test/tools/llvm-cov/Inputs/test.cpp.gcov
deleted file mode 100644
index a3dacc2..0000000
--- a/test/tools/llvm-cov/Inputs/test.cpp.gcov
+++ /dev/null
@@ -1,82 +0,0 @@
- -: 0:Source:test.cpp
- -: 0:Graph:test.gcno
- -: 0:Data:test.gcda
- -: 0:Runs:2
- -: 0:Programs:1
- -: 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:
- 4: 9:struct A {
- -: 10: virtual void B();
- -: 11:};
- -: 12:
-8589934592: 13:void A::B() {}
- -: 14:
- #####: 15:void useless() {}
- -: 16:
- -: 17:double more_useless() {
- #####: 18: return 0;
- -: 19:}
- -: 20:
- -: 21:int foo() {
- 2: 22: on = true;
- 2: 23: return 3;
- -: 24:}
- -: 25:
- -: 26:int bar() {
- #####: 27: len--;
- #####: 28: return foo() + 45;
- -: 29:}
- -: 30:
- 8: 31:void assign(int ii, int jj) {
- 8: 32: grid[ii][jj] = (ii+1) * (jj+1);
- 8: 33:}
- -: 34:
- -: 35:void initialize_grid() {
- 12: 36: for (int ii = 0; ii < 2; ii++)
- 24: 37: for (int jj = 0; jj < 2; jj++)
- 12: 38: assign(ii, jj);
- 2: 39:}
- -: 40:
- -: 41:int main() {
- 2: 42: initialize_grid();
- -: 43:
- 2: 44: int a = 2;
- 2: 45: on = rand() % 2;
- 2: 46: if (on) {
- 2: 47: foo();
- 2: 48: ++a;
- 2: 49: } else {
- #####: 50: bar();
- #####: 51: a += rand();
- -: 52: }
- -: 53:
- 44: 54: for (int ii = 0; ii < 10; ++ii) {
- 20: 55: switch (rand() % 5) {
- -: 56: case 0:
- 4: 57: a += rand();
- 4: 58: break;
- -: 59: case 1:
- -: 60: case 2:
- 2: 61: a += rand() / rand();
- 2: 62: break;
- -: 63: case 3:
- 6: 64: a -= rand();
- 6: 65: break;
- -: 66: default:
- 8: 67: a = -1;
- 8: 68: }
- 20: 69: }
- -: 70:
- 2: 71: A thing;
-17179869188: 72: for (uint64_t ii = 0; ii < 4294967296; ++ii)
-8589934592: 73: thing.B();
- -: 74:
- 2: 75: return a + 8 + grid[2][3] + len;
- -: 76: return more_useless();
- -: 77:}
diff --git a/test/tools/llvm-cov/Inputs/test.gcda b/test/tools/llvm-cov/Inputs/test.gcda
index 23d03bd..613e3a8 100644
--- a/test/tools/llvm-cov/Inputs/test.gcda
+++ b/test/tools/llvm-cov/Inputs/test.gcda
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/test.gcno b/test/tools/llvm-cov/Inputs/test.gcno
index 6162604..24f1c82 100644
--- a/test/tools/llvm-cov/Inputs/test.gcno
+++ b/test/tools/llvm-cov/Inputs/test.gcno
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/test.h b/test/tools/llvm-cov/Inputs/test.h
new file mode 100644
index 0000000..55d9c6a
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test.h
@@ -0,0 +1,3 @@
+struct A {
+ virtual void B();
+};
diff --git a/test/tools/llvm-cov/Inputs/test_-a.cpp.gcov b/test/tools/llvm-cov/Inputs/test_-a.cpp.gcov
new file mode 100644
index 0000000..c2210d5
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a.cpp.gcov
@@ -0,0 +1,111 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+8589934592: 10:void A::B() {}
+8589934592: 10-block 0
+ -: 11:
+ #####: 12:void useless() {}
+ $$$$$: 12-block 0
+ -: 13:
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ $$$$$: 15-block 0
+ -: 16:}
+ -: 17:
+ -: 18:int foo() {
+ 2: 19: on = true;
+ 2: 20: return 3;
+ 2: 20-block 0
+ -: 21:}
+ -: 22:
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ $$$$$: 25-block 0
+ -: 26:}
+ -: 27:
+ 8: 28:void assign(int ii, int jj) {
+ 8: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 8: 30:}
+ 8: 30-block 0
+ -: 31:
+ -: 32:void initialize_grid() {
+ 6: 33: for (int ii = 0; ii < 2; ii++)
+ 2: 33-block 0
+ 6: 33-block 1
+ 4: 33-block 2
+ 12: 34: for (int jj = 0; jj < 2; jj++)
+ 4: 34-block 0
+ 12: 34-block 1
+ 8: 34-block 2
+ 8: 35: assign(ii, jj);
+ 8: 35-block 0
+ 4: 35-block 1
+ 2: 36:}
+ 2: 36-block 0
+ -: 37:
+ -: 38:int main() {
+ 2: 39: initialize_grid();
+ -: 40:
+ 2: 41: int a = 2;
+ 2: 42: on = rand() % 2;
+ 2: 43: if (on) {
+ 2: 43-block 0
+ 2: 44: foo();
+ 2: 45: ++a;
+ 2: 46: } else {
+ 2: 46-block 0
+ #####: 47: bar();
+ #####: 48: a += rand();
+ $$$$$: 48-block 0
+ -: 49: }
+ -: 50:
+ 22: 51: for (int ii = 0; ii < 10; ++ii) {
+ 2: 51-block 0
+ 22: 51-block 1
+ 20: 51-block 2
+ 20: 52: switch (rand() % 5) {
+ 20: 52-block 0
+ -: 53: case 0:
+ 4: 54: a += rand();
+ 4: 55: break;
+ 4: 55-block 0
+ -: 56: case 1:
+ -: 57: case 2:
+ 2: 58: a += rand() / rand();
+ 2: 59: break;
+ 2: 59-block 0
+ -: 60: case 3:
+ 6: 61: a -= rand();
+ 6: 62: break;
+ 6: 62-block 0
+ -: 63: default:
+ 8: 64: a = -1;
+ 8: 65: }
+ 8: 65-block 0
+ 20: 66: }
+ 20: 66-block 0
+ -: 67:
+ 2: 68: A thing;
+8589934594: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+ 2: 69-block 0
+8589934594: 69-block 1
+8589934592: 69-block 2
+8589934592: 70: thing.B();
+8589934592: 70-block 0
+ -: 71:
+ 2: 72: return a + 8 + grid[2][3] + len;
+ 2: 72-block 0
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_-a.h.gcov b/test/tools/llvm-cov/Inputs/test_-a.h.gcov
new file mode 100644
index 0000000..a5fe62b
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a.h.gcov
@@ -0,0 +1,10 @@
+ -: 0:Source:./test.h
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ 2: 1:struct A {
+ 2: 1-block 0
+ 2: 1-block 1
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_-a_-b.cpp.gcov b/test/tools/llvm-cov/Inputs/test_-a_-b.cpp.gcov
new file mode 100644
index 0000000..ae21037
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a_-b.cpp.gcov
@@ -0,0 +1,134 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+function _ZN1A1BEv called 8589934592 returned 100% blocks executed 100%
+8589934592: 10:void A::B() {}
+8589934592: 10-block 0
+ -: 11:
+function _Z7uselessv called 0 returned 0% blocks executed 0%
+ #####: 12:void useless() {}
+ $$$$$: 12-block 0
+ -: 13:
+function _Z12more_uselessv called 0 returned 0% blocks executed 0%
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ $$$$$: 15-block 0
+ -: 16:}
+ -: 17:
+function _Z3foov called 2 returned 100% blocks executed 100%
+ -: 18:int foo() {
+ 2: 19: on = true;
+ 2: 20: return 3;
+ 2: 20-block 0
+ -: 21:}
+ -: 22:
+function _Z3barv called 0 returned 0% blocks executed 0%
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ $$$$$: 25-block 0
+ -: 26:}
+ -: 27:
+function _Z6assignii called 8 returned 100% blocks executed 100%
+ 8: 28:void assign(int ii, int jj) {
+ 8: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 8: 30:}
+ 8: 30-block 0
+ -: 31:
+function _Z15initialize_gridv called 2 returned 100% blocks executed 100%
+ -: 32:void initialize_grid() {
+ 6: 33: for (int ii = 0; ii < 2; ii++)
+ 2: 33-block 0
+ 6: 33-block 1
+branch 0 taken 67%
+branch 1 taken 33%
+ 4: 33-block 2
+ 12: 34: for (int jj = 0; jj < 2; jj++)
+ 4: 34-block 0
+ 12: 34-block 1
+branch 0 taken 67%
+branch 1 taken 33%
+ 8: 34-block 2
+ 8: 35: assign(ii, jj);
+ 8: 35-block 0
+ 4: 35-block 1
+ 2: 36:}
+ 2: 36-block 0
+ -: 37:
+function main called 2 returned 100% blocks executed 94%
+ -: 38:int main() {
+ 2: 39: initialize_grid();
+ -: 40:
+ 2: 41: int a = 2;
+ 2: 42: on = rand() % 2;
+ 2: 43: if (on) {
+ 2: 43-block 0
+branch 0 taken 100%
+branch 1 taken 0%
+ 2: 44: foo();
+ 2: 45: ++a;
+ 2: 46: } else {
+ 2: 46-block 0
+ #####: 47: bar();
+ #####: 48: a += rand();
+ $$$$$: 48-block 0
+ -: 49: }
+ -: 50:
+ 22: 51: for (int ii = 0; ii < 10; ++ii) {
+ 2: 51-block 0
+ 22: 51-block 1
+branch 0 taken 91%
+branch 1 taken 9%
+ 20: 51-block 2
+ 20: 52: switch (rand() % 5) {
+ 20: 52-block 0
+branch 0 taken 20%
+branch 1 taken 0%
+branch 2 taken 10%
+branch 3 taken 30%
+branch 4 taken 40%
+ -: 53: case 0:
+ 4: 54: a += rand();
+ 4: 55: break;
+ 4: 55-block 0
+ -: 56: case 1:
+ -: 57: case 2:
+ 2: 58: a += rand() / rand();
+ 2: 59: break;
+ 2: 59-block 0
+ -: 60: case 3:
+ 6: 61: a -= rand();
+ 6: 62: break;
+ 6: 62-block 0
+ -: 63: default:
+ 8: 64: a = -1;
+ 8: 65: }
+ 8: 65-block 0
+ 20: 66: }
+ 20: 66-block 0
+ -: 67:
+ 2: 68: A thing;
+8589934594: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+ 2: 69-block 0
+8589934594: 69-block 1
+branch 0 taken 99%
+branch 1 taken 1%
+8589934592: 69-block 2
+8589934592: 70: thing.B();
+8589934592: 70-block 0
+ -: 71:
+ 2: 72: return a + 8 + grid[2][3] + len;
+ 2: 72-block 0
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_-a_-b.h.gcov b/test/tools/llvm-cov/Inputs/test_-a_-b.h.gcov
new file mode 100644
index 0000000..f3dabcb
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a_-b.h.gcov
@@ -0,0 +1,12 @@
+ -: 0:Source:./test.h
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+function _ZN1AC1Ev called 2 returned 100% blocks executed 100%
+function _ZN1AC2Ev called 2 returned 100% blocks executed 100%
+ 2: 1:struct A {
+ 2: 1-block 0
+ 2: 1-block 1
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.cpp.gcov b/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.cpp.gcov
new file mode 100644
index 0000000..cc5940f
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.cpp.gcov
@@ -0,0 +1,160 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+function _ZN1A1BEv called 8589934592 returned 100% blocks executed 100%
+8589934592: 10:void A::B() {}
+8589934592: 10-block 0
+unconditional 0 taken 8589934592
+ -: 11:
+function _Z7uselessv called 0 returned 0% blocks executed 0%
+ #####: 12:void useless() {}
+ $$$$$: 12-block 0
+unconditional 0 never executed
+ -: 13:
+function _Z12more_uselessv called 0 returned 0% blocks executed 0%
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ $$$$$: 15-block 0
+unconditional 0 never executed
+ -: 16:}
+ -: 17:
+function _Z3foov called 2 returned 100% blocks executed 100%
+ -: 18:int foo() {
+ 2: 19: on = true;
+ 2: 20: return 3;
+ 2: 20-block 0
+unconditional 0 taken 2
+ -: 21:}
+ -: 22:
+function _Z3barv called 0 returned 0% blocks executed 0%
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ $$$$$: 25-block 0
+unconditional 0 never executed
+ -: 26:}
+ -: 27:
+function _Z6assignii called 8 returned 100% blocks executed 100%
+ 8: 28:void assign(int ii, int jj) {
+ 8: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 8: 30:}
+ 8: 30-block 0
+unconditional 0 taken 8
+ -: 31:
+function _Z15initialize_gridv called 2 returned 100% blocks executed 100%
+ -: 32:void initialize_grid() {
+ 6: 33: for (int ii = 0; ii < 2; ii++)
+ 2: 33-block 0
+unconditional 0 taken 2
+ 6: 33-block 1
+branch 1 taken 4
+branch 2 taken 2
+ 4: 33-block 2
+unconditional 3 taken 4
+ 12: 34: for (int jj = 0; jj < 2; jj++)
+ 4: 34-block 0
+unconditional 0 taken 4
+ 12: 34-block 1
+branch 1 taken 8
+branch 2 taken 4
+ 8: 34-block 2
+unconditional 3 taken 8
+ 8: 35: assign(ii, jj);
+ 8: 35-block 0
+unconditional 0 taken 8
+ 4: 35-block 1
+unconditional 1 taken 4
+ 2: 36:}
+ 2: 36-block 0
+unconditional 0 taken 2
+ -: 37:
+function main called 2 returned 100% blocks executed 94%
+ -: 38:int main() {
+ 2: 39: initialize_grid();
+ -: 40:
+ 2: 41: int a = 2;
+ 2: 42: on = rand() % 2;
+ 2: 43: if (on) {
+ 2: 43-block 0
+branch 0 taken 2
+branch 1 taken 0
+ 2: 44: foo();
+ 2: 45: ++a;
+ 2: 46: } else {
+ 2: 46-block 0
+unconditional 0 taken 2
+ #####: 47: bar();
+ #####: 48: a += rand();
+ $$$$$: 48-block 0
+unconditional 0 never executed
+ -: 49: }
+ -: 50:
+ 22: 51: for (int ii = 0; ii < 10; ++ii) {
+ 2: 51-block 0
+unconditional 0 taken 2
+ 22: 51-block 1
+branch 1 taken 20
+branch 2 taken 2
+ 20: 51-block 2
+unconditional 3 taken 20
+ 20: 52: switch (rand() % 5) {
+ 20: 52-block 0
+branch 0 taken 4
+branch 1 taken 0
+branch 2 taken 2
+branch 3 taken 6
+branch 4 taken 8
+ -: 53: case 0:
+ 4: 54: a += rand();
+ 4: 55: break;
+ 4: 55-block 0
+unconditional 0 taken 4
+ -: 56: case 1:
+ -: 57: case 2:
+ 2: 58: a += rand() / rand();
+ 2: 59: break;
+ 2: 59-block 0
+unconditional 0 taken 2
+ -: 60: case 3:
+ 6: 61: a -= rand();
+ 6: 62: break;
+ 6: 62-block 0
+unconditional 0 taken 6
+ -: 63: default:
+ 8: 64: a = -1;
+ 8: 65: }
+ 8: 65-block 0
+unconditional 0 taken 8
+ 20: 66: }
+ 20: 66-block 0
+unconditional 0 taken 20
+ -: 67:
+ 2: 68: A thing;
+8589934594: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+ 2: 69-block 0
+unconditional 0 taken 2
+8589934594: 69-block 1
+branch 1 taken 8589934592
+branch 2 taken 2
+8589934592: 69-block 2
+unconditional 3 taken 8589934592
+8589934592: 70: thing.B();
+8589934592: 70-block 0
+unconditional 0 taken 8589934592
+ -: 71:
+ 2: 72: return a + 8 + grid[2][3] + len;
+ 2: 72-block 0
+unconditional 0 taken 2
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.h.gcov b/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.h.gcov
new file mode 100644
index 0000000..840324e
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a_-b_-c_-u.h.gcov
@@ -0,0 +1,14 @@
+ -: 0:Source:./test.h
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+function _ZN1AC1Ev called 2 returned 100% blocks executed 100%
+function _ZN1AC2Ev called 2 returned 100% blocks executed 100%
+ 2: 1:struct A {
+ 2: 1-block 0
+unconditional 0 taken 2
+ 2: 1-block 1
+unconditional 1 taken 2
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_-a_-b_-u.cpp.gcov b/test/tools/llvm-cov/Inputs/test_-a_-b_-u.cpp.gcov
new file mode 100644
index 0000000..0d2c6b3
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a_-b_-u.cpp.gcov
@@ -0,0 +1,160 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+function _ZN1A1BEv called 8589934592 returned 100% blocks executed 100%
+8589934592: 10:void A::B() {}
+8589934592: 10-block 0
+unconditional 0 taken 100%
+ -: 11:
+function _Z7uselessv called 0 returned 0% blocks executed 0%
+ #####: 12:void useless() {}
+ $$$$$: 12-block 0
+unconditional 0 never executed
+ -: 13:
+function _Z12more_uselessv called 0 returned 0% blocks executed 0%
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ $$$$$: 15-block 0
+unconditional 0 never executed
+ -: 16:}
+ -: 17:
+function _Z3foov called 2 returned 100% blocks executed 100%
+ -: 18:int foo() {
+ 2: 19: on = true;
+ 2: 20: return 3;
+ 2: 20-block 0
+unconditional 0 taken 100%
+ -: 21:}
+ -: 22:
+function _Z3barv called 0 returned 0% blocks executed 0%
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ $$$$$: 25-block 0
+unconditional 0 never executed
+ -: 26:}
+ -: 27:
+function _Z6assignii called 8 returned 100% blocks executed 100%
+ 8: 28:void assign(int ii, int jj) {
+ 8: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 8: 30:}
+ 8: 30-block 0
+unconditional 0 taken 100%
+ -: 31:
+function _Z15initialize_gridv called 2 returned 100% blocks executed 100%
+ -: 32:void initialize_grid() {
+ 6: 33: for (int ii = 0; ii < 2; ii++)
+ 2: 33-block 0
+unconditional 0 taken 100%
+ 6: 33-block 1
+branch 1 taken 67%
+branch 2 taken 33%
+ 4: 33-block 2
+unconditional 3 taken 100%
+ 12: 34: for (int jj = 0; jj < 2; jj++)
+ 4: 34-block 0
+unconditional 0 taken 100%
+ 12: 34-block 1
+branch 1 taken 67%
+branch 2 taken 33%
+ 8: 34-block 2
+unconditional 3 taken 100%
+ 8: 35: assign(ii, jj);
+ 8: 35-block 0
+unconditional 0 taken 100%
+ 4: 35-block 1
+unconditional 1 taken 100%
+ 2: 36:}
+ 2: 36-block 0
+unconditional 0 taken 100%
+ -: 37:
+function main called 2 returned 100% blocks executed 94%
+ -: 38:int main() {
+ 2: 39: initialize_grid();
+ -: 40:
+ 2: 41: int a = 2;
+ 2: 42: on = rand() % 2;
+ 2: 43: if (on) {
+ 2: 43-block 0
+branch 0 taken 100%
+branch 1 taken 0%
+ 2: 44: foo();
+ 2: 45: ++a;
+ 2: 46: } else {
+ 2: 46-block 0
+unconditional 0 taken 100%
+ #####: 47: bar();
+ #####: 48: a += rand();
+ $$$$$: 48-block 0
+unconditional 0 never executed
+ -: 49: }
+ -: 50:
+ 22: 51: for (int ii = 0; ii < 10; ++ii) {
+ 2: 51-block 0
+unconditional 0 taken 100%
+ 22: 51-block 1
+branch 1 taken 91%
+branch 2 taken 9%
+ 20: 51-block 2
+unconditional 3 taken 100%
+ 20: 52: switch (rand() % 5) {
+ 20: 52-block 0
+branch 0 taken 20%
+branch 1 taken 0%
+branch 2 taken 10%
+branch 3 taken 30%
+branch 4 taken 40%
+ -: 53: case 0:
+ 4: 54: a += rand();
+ 4: 55: break;
+ 4: 55-block 0
+unconditional 0 taken 100%
+ -: 56: case 1:
+ -: 57: case 2:
+ 2: 58: a += rand() / rand();
+ 2: 59: break;
+ 2: 59-block 0
+unconditional 0 taken 100%
+ -: 60: case 3:
+ 6: 61: a -= rand();
+ 6: 62: break;
+ 6: 62-block 0
+unconditional 0 taken 100%
+ -: 63: default:
+ 8: 64: a = -1;
+ 8: 65: }
+ 8: 65-block 0
+unconditional 0 taken 100%
+ 20: 66: }
+ 20: 66-block 0
+unconditional 0 taken 100%
+ -: 67:
+ 2: 68: A thing;
+8589934594: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+ 2: 69-block 0
+unconditional 0 taken 100%
+8589934594: 69-block 1
+branch 1 taken 99%
+branch 2 taken 1%
+8589934592: 69-block 2
+unconditional 3 taken 100%
+8589934592: 70: thing.B();
+8589934592: 70-block 0
+unconditional 0 taken 100%
+ -: 71:
+ 2: 72: return a + 8 + grid[2][3] + len;
+ 2: 72-block 0
+unconditional 0 taken 100%
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_-a_-b_-u.h.gcov b/test/tools/llvm-cov/Inputs/test_-a_-b_-u.h.gcov
new file mode 100644
index 0000000..e7fa658
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-a_-b_-u.h.gcov
@@ -0,0 +1,14 @@
+ -: 0:Source:./test.h
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+function _ZN1AC1Ev called 2 returned 100% blocks executed 100%
+function _ZN1AC2Ev called 2 returned 100% blocks executed 100%
+ 2: 1:struct A {
+ 2: 1-block 0
+unconditional 0 taken 100%
+ 2: 1-block 1
+unconditional 1 taken 100%
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_-b.output b/test/tools/llvm-cov/Inputs/test_-b.output
new file mode 100644
index 0000000..515987d
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-b.output
@@ -0,0 +1,13 @@
+File 'test.cpp'
+Lines executed:84.21% of 38
+Branches executed:100.00% of 15
+Taken at least once:86.67% of 15
+No calls
+test.cpp:creating 'test.cpp.gcov'
+
+File './test.h'
+Lines executed:100.00% of 1
+No branches
+No calls
+./test.h:creating 'test.h.gcov'
+
diff --git a/test/tools/llvm-cov/Inputs/test_-b_-f.output b/test/tools/llvm-cov/Inputs/test_-b_-f.output
new file mode 100644
index 0000000..c3ccd05
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-b_-f.output
@@ -0,0 +1,65 @@
+Function '_ZN1A1BEv'
+Lines executed:100.00% of 1
+No branches
+No calls
+
+Function '_Z7uselessv'
+Lines executed:0.00% of 1
+No branches
+No calls
+
+Function '_Z12more_uselessv'
+Lines executed:0.00% of 1
+No branches
+No calls
+
+Function '_Z3foov'
+Lines executed:100.00% of 2
+No branches
+No calls
+
+Function '_Z3barv'
+Lines executed:0.00% of 2
+No branches
+No calls
+
+Function '_Z6assignii'
+Lines executed:100.00% of 3
+No branches
+No calls
+
+Function '_Z15initialize_gridv'
+Lines executed:100.00% of 4
+Branches executed:100.00% of 4
+Taken at least once:100.00% of 4
+No calls
+
+Function 'main'
+Lines executed:91.67% of 24
+Branches executed:100.00% of 11
+Taken at least once:81.82% of 11
+No calls
+
+Function '_ZN1AC1Ev'
+Lines executed:100.00% of 1
+No branches
+No calls
+
+Function '_ZN1AC2Ev'
+No executable lines
+No branches
+No calls
+
+File 'test.cpp'
+Lines executed:84.21% of 38
+Branches executed:100.00% of 15
+Taken at least once:86.67% of 15
+No calls
+test.cpp:creating 'test.cpp.gcov'
+
+File './test.h'
+Lines executed:100.00% of 1
+No branches
+No calls
+./test.h:creating 'test.h.gcov'
+
diff --git a/test/tools/llvm-cov/Inputs/test_-f.output b/test/tools/llvm-cov/Inputs/test_-f.output
new file mode 100644
index 0000000..d97aa18
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_-f.output
@@ -0,0 +1,38 @@
+Function '_ZN1A1BEv'
+Lines executed:100.00% of 1
+
+Function '_Z7uselessv'
+Lines executed:0.00% of 1
+
+Function '_Z12more_uselessv'
+Lines executed:0.00% of 1
+
+Function '_Z3foov'
+Lines executed:100.00% of 2
+
+Function '_Z3barv'
+Lines executed:0.00% of 2
+
+Function '_Z6assignii'
+Lines executed:100.00% of 3
+
+Function '_Z15initialize_gridv'
+Lines executed:100.00% of 4
+
+Function 'main'
+Lines executed:91.67% of 24
+
+Function '_ZN1AC1Ev'
+Lines executed:100.00% of 1
+
+Function '_ZN1AC2Ev'
+Lines executed:100.00% of 1
+
+File 'test.cpp'
+Lines executed:84.21% of 38
+test.cpp:creating 'test.cpp.gcov'
+
+File './test.h'
+Lines executed:100.00% of 1
+./test.h:creating 'test.h.gcov'
+
diff --git a/test/tools/llvm-cov/Inputs/test_file_checksum_fail.gcda b/test/tools/llvm-cov/Inputs/test_file_checksum_fail.gcda
new file mode 100644
index 0000000..8bfd82c
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_file_checksum_fail.gcda
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/test_func_checksum_fail.gcda b/test/tools/llvm-cov/Inputs/test_func_checksum_fail.gcda
new file mode 100644
index 0000000..4c729a8
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_func_checksum_fail.gcda
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/test_no_gcda.cpp.gcov b/test/tools/llvm-cov/Inputs/test_no_gcda.cpp.gcov
new file mode 100644
index 0000000..31353ca
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_no_gcda.cpp.gcov
@@ -0,0 +1,79 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:test.gcno
+ -: 0:Data:-
+ -: 0:Runs:0
+ -: 0:Programs:0
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+ #####: 10:void A::B() {}
+ -: 11:
+ #####: 12:void useless() {}
+ -: 13:
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ -: 16:}
+ -: 17:
+ -: 18:int foo() {
+ #####: 19: on = true;
+ #####: 20: return 3;
+ -: 21:}
+ -: 22:
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ -: 26:}
+ -: 27:
+ #####: 28:void assign(int ii, int jj) {
+ #####: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ #####: 30:}
+ -: 31:
+ -: 32:void initialize_grid() {
+ #####: 33: for (int ii = 0; ii < 2; ii++)
+ #####: 34: for (int jj = 0; jj < 2; jj++)
+ #####: 35: assign(ii, jj);
+ #####: 36:}
+ -: 37:
+ -: 38:int main() {
+ #####: 39: initialize_grid();
+ -: 40:
+ #####: 41: int a = 2;
+ #####: 42: on = rand() % 2;
+ #####: 43: if (on) {
+ #####: 44: foo();
+ #####: 45: ++a;
+ #####: 46: } else {
+ #####: 47: bar();
+ #####: 48: a += rand();
+ -: 49: }
+ -: 50:
+ #####: 51: for (int ii = 0; ii < 10; ++ii) {
+ #####: 52: switch (rand() % 5) {
+ -: 53: case 0:
+ #####: 54: a += rand();
+ #####: 55: break;
+ -: 56: case 1:
+ -: 57: case 2:
+ #####: 58: a += rand() / rand();
+ #####: 59: break;
+ -: 60: case 3:
+ #####: 61: a -= rand();
+ #####: 62: break;
+ -: 63: default:
+ #####: 64: a = -1;
+ #####: 65: }
+ #####: 66: }
+ -: 67:
+ #####: 68: A thing;
+ #####: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+ #####: 70: thing.B();
+ -: 71:
+ #####: 72: return a + 8 + grid[2][3] + len;
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_no_gcda.h.gcov b/test/tools/llvm-cov/Inputs/test_no_gcda.h.gcov
new file mode 100644
index 0000000..c0a45c6
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_no_gcda.h.gcov
@@ -0,0 +1,8 @@
+ -: 0:Source:./test.h
+ -: 0:Graph:test.gcno
+ -: 0:Data:-
+ -: 0:Runs:0
+ -: 0:Programs:0
+ #####: 1:struct A {
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_no_gcda.output b/test/tools/llvm-cov/Inputs/test_no_gcda.output
new file mode 100644
index 0000000..e994be7
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_no_gcda.output
@@ -0,0 +1,8 @@
+File 'test.cpp'
+Lines executed:0.00% of 38
+test.cpp:creating 'test.cpp.gcov'
+
+File './test.h'
+Lines executed:0.00% of 1
+./test.h:creating 'test.h.gcov'
+
diff --git a/test/tools/llvm-cov/Inputs/test_no_options.cpp.gcov b/test/tools/llvm-cov/Inputs/test_no_options.cpp.gcov
new file mode 100644
index 0000000..871e3ba
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_no_options.cpp.gcov
@@ -0,0 +1,79 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+8589934592: 10:void A::B() {}
+ -: 11:
+ #####: 12:void useless() {}
+ -: 13:
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ -: 16:}
+ -: 17:
+ -: 18:int foo() {
+ 2: 19: on = true;
+ 2: 20: return 3;
+ -: 21:}
+ -: 22:
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ -: 26:}
+ -: 27:
+ 8: 28:void assign(int ii, int jj) {
+ 8: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 8: 30:}
+ -: 31:
+ -: 32:void initialize_grid() {
+ 12: 33: for (int ii = 0; ii < 2; ii++)
+ 24: 34: for (int jj = 0; jj < 2; jj++)
+ 12: 35: assign(ii, jj);
+ 2: 36:}
+ -: 37:
+ -: 38:int main() {
+ 2: 39: initialize_grid();
+ -: 40:
+ 2: 41: int a = 2;
+ 2: 42: on = rand() % 2;
+ 2: 43: if (on) {
+ 2: 44: foo();
+ 2: 45: ++a;
+ 2: 46: } else {
+ #####: 47: bar();
+ #####: 48: a += rand();
+ -: 49: }
+ -: 50:
+ 44: 51: for (int ii = 0; ii < 10; ++ii) {
+ 20: 52: switch (rand() % 5) {
+ -: 53: case 0:
+ 4: 54: a += rand();
+ 4: 55: break;
+ -: 56: case 1:
+ -: 57: case 2:
+ 2: 58: a += rand() / rand();
+ 2: 59: break;
+ -: 60: case 3:
+ 6: 61: a -= rand();
+ 6: 62: break;
+ -: 63: default:
+ 8: 64: a = -1;
+ 8: 65: }
+ 20: 66: }
+ -: 67:
+ 2: 68: A thing;
+17179869188: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+8589934592: 70: thing.B();
+ -: 71:
+ 2: 72: return a + 8 + grid[2][3] + len;
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_no_options.h.gcov b/test/tools/llvm-cov/Inputs/test_no_options.h.gcov
new file mode 100644
index 0000000..4ba58c9
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_no_options.h.gcov
@@ -0,0 +1,8 @@
+ -: 0:Source:./test.h
+ -: 0:Graph:test.gcno
+ -: 0:Data:test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ 4: 1:struct A {
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_no_options.output b/test/tools/llvm-cov/Inputs/test_no_options.output
new file mode 100644
index 0000000..8be8c1c
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_no_options.output
@@ -0,0 +1,8 @@
+File 'test.cpp'
+Lines executed:84.21% of 38
+test.cpp:creating 'test.cpp.gcov'
+
+File './test.h'
+Lines executed:100.00% of 1
+./test.h:creating 'test.h.gcov'
+
diff --git a/test/tools/llvm-cov/Inputs/test_no_preserve_paths.output b/test/tools/llvm-cov/Inputs/test_no_preserve_paths.output
new file mode 100644
index 0000000..ada0c36
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_no_preserve_paths.output
@@ -0,0 +1,8 @@
+File 'srcdir/./nested_dir/../test.h'
+Lines executed:100.00% of 1
+srcdir/./nested_dir/../test.h:creating 'test.h.gcov'
+
+File 'srcdir/./nested_dir/../test.cpp'
+Lines executed:84.21% of 38
+srcdir/./nested_dir/../test.cpp:creating 'test.cpp.gcov'
+
diff --git a/test/tools/llvm-cov/Inputs/test_objdir.cpp.gcov b/test/tools/llvm-cov/Inputs/test_objdir.cpp.gcov
new file mode 100644
index 0000000..abf8856
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_objdir.cpp.gcov
@@ -0,0 +1,79 @@
+ -: 0:Source:test.cpp
+ -: 0:Graph:objdir/test.gcno
+ -: 0:Data:objdir/test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+8589934592: 10:void A::B() {}
+ -: 11:
+ #####: 12:void useless() {}
+ -: 13:
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ -: 16:}
+ -: 17:
+ -: 18:int foo() {
+ 2: 19: on = true;
+ 2: 20: return 3;
+ -: 21:}
+ -: 22:
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ -: 26:}
+ -: 27:
+ 8: 28:void assign(int ii, int jj) {
+ 8: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 8: 30:}
+ -: 31:
+ -: 32:void initialize_grid() {
+ 12: 33: for (int ii = 0; ii < 2; ii++)
+ 24: 34: for (int jj = 0; jj < 2; jj++)
+ 12: 35: assign(ii, jj);
+ 2: 36:}
+ -: 37:
+ -: 38:int main() {
+ 2: 39: initialize_grid();
+ -: 40:
+ 2: 41: int a = 2;
+ 2: 42: on = rand() % 2;
+ 2: 43: if (on) {
+ 2: 44: foo();
+ 2: 45: ++a;
+ 2: 46: } else {
+ #####: 47: bar();
+ #####: 48: a += rand();
+ -: 49: }
+ -: 50:
+ 44: 51: for (int ii = 0; ii < 10; ++ii) {
+ 20: 52: switch (rand() % 5) {
+ -: 53: case 0:
+ 4: 54: a += rand();
+ 4: 55: break;
+ -: 56: case 1:
+ -: 57: case 2:
+ 2: 58: a += rand() / rand();
+ 2: 59: break;
+ -: 60: case 3:
+ 6: 61: a -= rand();
+ 6: 62: break;
+ -: 63: default:
+ 8: 64: a = -1;
+ 8: 65: }
+ 20: 66: }
+ -: 67:
+ 2: 68: A thing;
+17179869188: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+8589934592: 70: thing.B();
+ -: 71:
+ 2: 72: return a + 8 + grid[2][3] + len;
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_objdir.h.gcov b/test/tools/llvm-cov/Inputs/test_objdir.h.gcov
new file mode 100644
index 0000000..8208d25
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_objdir.h.gcov
@@ -0,0 +1,8 @@
+ -: 0:Source:./test.h
+ -: 0:Graph:objdir/test.gcno
+ -: 0:Data:objdir/test.gcda
+ -: 0:Runs:2
+ -: 0:Programs:1
+ 4: 1:struct A {
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_paths.cpp.gcov b/test/tools/llvm-cov/Inputs/test_paths.cpp.gcov
new file mode 100644
index 0000000..3982ddf
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_paths.cpp.gcov
@@ -0,0 +1,79 @@
+ -: 0:Source:srcdir/./nested_dir/../test.cpp
+ -: 0:Graph:test_paths.gcno
+ -: 0:Data:test_paths.gcda
+ -: 0:Runs:3
+ -: 0:Programs:1
+ -: 1:#include "test.h"
+ -: 2:#include <cstdlib>
+ -: 3:
+ -: 4:bool on = false;
+ -: 5:int len = 42;
+ -: 6:double grid[10][10] = {0};
+ -: 7:const char * hello = "world";
+ -: 8:const char * world = "hello";
+ -: 9:
+12884901888: 10:void A::B() {}
+ -: 11:
+ #####: 12:void useless() {}
+ -: 13:
+ -: 14:double more_useless() {
+ #####: 15: return 0;
+ -: 16:}
+ -: 17:
+ -: 18:int foo() {
+ 3: 19: on = true;
+ 3: 20: return 3;
+ -: 21:}
+ -: 22:
+ -: 23:int bar() {
+ #####: 24: len--;
+ #####: 25: return foo() + 45;
+ -: 26:}
+ -: 27:
+ 12: 28:void assign(int ii, int jj) {
+ 12: 29: grid[ii][jj] = (ii+1) * (jj+1);
+ 12: 30:}
+ -: 31:
+ -: 32:void initialize_grid() {
+ 21: 33: for (int ii = 0; ii < 2; ii++)
+ 36: 34: for (int jj = 0; jj < 2; jj++)
+ 18: 35: assign(ii, jj);
+ 3: 36:}
+ -: 37:
+ -: 38:int main() {
+ 3: 39: initialize_grid();
+ -: 40:
+ 3: 41: int a = 2;
+ 3: 42: on = rand() % 2;
+ 3: 43: if (on) {
+ 3: 44: foo();
+ 3: 45: ++a;
+ 3: 46: } else {
+ #####: 47: bar();
+ #####: 48: a += rand();
+ -: 49: }
+ -: 50:
+ 66: 51: for (int ii = 0; ii < 10; ++ii) {
+ 30: 52: switch (rand() % 5) {
+ -: 53: case 0:
+ 6: 54: a += rand();
+ 6: 55: break;
+ -: 56: case 1:
+ -: 57: case 2:
+ 3: 58: a += rand() / rand();
+ 3: 59: break;
+ -: 60: case 3:
+ 9: 61: a -= rand();
+ 9: 62: break;
+ -: 63: default:
+ 12: 64: a = -1;
+ 12: 65: }
+ 30: 66: }
+ -: 67:
+ 3: 68: A thing;
+25769803782: 69: for (uint64_t ii = 0; ii < 4294967296; ++ii)
+12884901888: 70: thing.B();
+ -: 71:
+ 3: 72: return a + 8 + grid[2][3] + len;
+ -: 73: return more_useless();
+ -: 74:}
diff --git a/test/tools/llvm-cov/Inputs/test_paths.gcda b/test/tools/llvm-cov/Inputs/test_paths.gcda
new file mode 100644
index 0000000..7e2cf9e
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_paths.gcda
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/test_paths.gcno b/test/tools/llvm-cov/Inputs/test_paths.gcno
new file mode 100644
index 0000000..aada974
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_paths.gcno
Binary files differ
diff --git a/test/tools/llvm-cov/Inputs/test_paths.h.gcov b/test/tools/llvm-cov/Inputs/test_paths.h.gcov
new file mode 100644
index 0000000..95e90ca
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_paths.h.gcov
@@ -0,0 +1,8 @@
+ -: 0:Source:srcdir/./nested_dir/../test.h
+ -: 0:Graph:test_paths.gcno
+ -: 0:Data:test_paths.gcda
+ -: 0:Runs:3
+ -: 0:Programs:1
+ 6: 1:struct A {
+ -: 2: virtual void B();
+ -: 3:};
diff --git a/test/tools/llvm-cov/Inputs/test_preserve_paths.output b/test/tools/llvm-cov/Inputs/test_preserve_paths.output
new file mode 100644
index 0000000..5331972
--- /dev/null
+++ b/test/tools/llvm-cov/Inputs/test_preserve_paths.output
@@ -0,0 +1,8 @@
+File 'srcdir/./nested_dir/../test.h'
+Lines executed:100.00% of 1
+srcdir/./nested_dir/../test.h:creating 'srcdir#nested_dir#^#test.h.gcov'
+
+File 'srcdir/./nested_dir/../test.cpp'
+Lines executed:84.21% of 38
+srcdir/./nested_dir/../test.cpp:creating 'srcdir#nested_dir#^#test.cpp.gcov'
+
diff --git a/test/tools/llvm-cov/Inputs/test_read_fail.gcno b/test/tools/llvm-cov/Inputs/test_read_fail.gcno
index 63b5d71..88073f1 100644
--- a/test/tools/llvm-cov/Inputs/test_read_fail.gcno
+++ b/test/tools/llvm-cov/Inputs/test_read_fail.gcno
Binary files differ
diff --git a/test/tools/llvm-cov/copy_block_helper.m b/test/tools/llvm-cov/copy_block_helper.m
new file mode 100644
index 0000000..1859b88
--- /dev/null
+++ b/test/tools/llvm-cov/copy_block_helper.m
@@ -0,0 +1,32 @@
+// Make sure that compiler-added functions (whose line number is zero) don't
+// crash llvm-cov.
+
+// We need shell for cd
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cd %t
+// RUN: cp %s %p/Inputs/copy_block_helper.gc* .
+
+// RUN: llvm-cov copy_block_helper.m | FileCheck %s --check-prefix=STDOUT
+// STDOUT: File 'copy_block_helper.m'
+// STDOUT: Lines executed:100.00% of 5
+// STDOUT: copy_block_helper.m:creating 'copy_block_helper.m.gcov'
+
+// RUN: FileCheck %s --check-prefix=GCOV < %t/copy_block_helper.m.gcov
+// GCOV: -: 0:Runs:1
+// GCOV: -: 0:Programs:1
+
+id test_helper(id (^foo)(void)) { return foo(); } // GCOV: 1: [[@LINE]]:id
+void test(id x) { // GCOV: -: [[@LINE]]:void test
+ test_helper(^{ // GCOV: 2: [[@LINE]]: test_helper
+ return x; // GCOV: 1: [[@LINE]]: return
+ }); // GCOV: -: [[@LINE]]:
+} // GCOV: 1: [[@LINE]]:}
+
+// GCOV: 1: [[@LINE+1]]:int main
+int main(int argc, const char *argv[]) { test(0); }
+
+// llvm-cov doesn't work on big endian yet
+// XFAIL: powerpc64, s390x, mips-, mips64-, sparc
diff --git a/test/tools/llvm-cov/lit.local.cfg b/test/tools/llvm-cov/lit.local.cfg
index df9b335..f738810 100644
--- a/test/tools/llvm-cov/lit.local.cfg
+++ b/test/tools/llvm-cov/lit.local.cfg
@@ -1 +1 @@
-config.suffixes = ['.test']
+config.suffixes = ['.test', '.m']
diff --git a/test/tools/llvm-cov/llvm-cov.test b/test/tools/llvm-cov/llvm-cov.test
index 28738a7..19d3e5d 100644
--- a/test/tools/llvm-cov/llvm-cov.test
+++ b/test/tools/llvm-cov/llvm-cov.test
@@ -1,10 +1,94 @@
-RUN: cd %p/Inputs
-# "cd" is unsupported in lit internal runner.
+# Tests for compatibility between llvm-cov and gcov. These work by
+# comparing llvm-cov against reference outputs generated by gcov 4.2.
+
+# "cd" and globbing are unsupported in lit internal runner.
REQUIRES: shell
-RUN: llvm-cov -gcno=test.gcno -gcda=test.gcda \
-RUN: | diff -aub test.cpp.gcov -
+RUN: rm -rf %t
+RUN: mkdir %t
+RUN: cd %t
+RUN: cp %p/Inputs/test* .
+
+# Basic behaviour with no flags
+RUN: llvm-cov test.c | diff -u test_no_options.output -
+RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_no_options.h.gcov test.h.gcov
+
+# Same, but specifying the object directory
+RUN: mkdir -p %t/objdir
+RUN: cp test.gcno test.gcda %t/objdir
+RUN: llvm-cov -o objdir test.c | diff -u test_no_options.output -
+RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_objdir.h.gcov test.h.gcov
+
+# Specifying an object file
+RUN: llvm-cov -o objdir/test.o test.c | diff -u test_no_options.output -
+RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_objdir.h.gcov test.h.gcov
+
+# Specifying an object file that could be ambiguous with a directory
+RUN: llvm-cov -o objdir/test test.c | diff -u test_no_options.output -
+RUN: diff -aub test_objdir.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_objdir.h.gcov test.h.gcov
+
+# Preserve paths. This mangles the output filenames.
+RUN: mkdir -p %t/srcdir/nested_dir
+RUN: cp test.cpp test.h %t/srcdir
+RUN: llvm-cov -p test_paths.cpp | diff -u test_preserve_paths.output -
+RUN: diff -aub test_paths.cpp.gcov srcdir#nested_dir#^#test.cpp.gcov
+RUN: diff -aub test_paths.h.gcov srcdir#nested_dir#^#test.h.gcov
+
+# Don't preserve paths. Same results as preserve paths, but no mangling.
+RUN: llvm-cov test_paths.cpp | diff -u test_no_preserve_paths.output -
+RUN: diff -aub test_paths.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_paths.h.gcov test.h.gcov
+
+# Function summaries. This changes stdout, but not the gcov files.
+RUN: llvm-cov test.c -f | diff -u test_-f.output -
+RUN: diff -aub test_no_options.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_no_options.h.gcov test.h.gcov
+
+# All blocks. This doesn't affect stdout, only the gcov files.
+RUN: llvm-cov test.c -a | diff -u test_no_options.output -
+RUN: diff -aub test_-a.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_-a.h.gcov test.h.gcov
+
+# Branch probabilities.
+RUN: llvm-cov test.c -a -b | diff -u test_-b.output -
+RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
+
+# Function summaries including branch probabilities.
+
+# FIXME: We don't correctly handle calls when -b and -f are used
+# together, so our output differs from gcov. Remove the 'not' from
+# this test once this is fixed.
+RUN: llvm-cov test.c -a -b -f | not diff -u test_-b_-f.output - >/dev/null
+RUN: diff -aub test_-a_-b.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_-a_-b.h.gcov test.h.gcov
+
+# Summarize unconditional branches too.
+RUN: llvm-cov test.c -a -b -u | diff -u test_-b.output -
+RUN: diff -aub test_-a_-b_-u.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_-a_-b_-u.h.gcov test.h.gcov
+
+# Absolute counts for branches.
+RUN: llvm-cov test.c -a -b -c -u | diff -u test_-b.output -
+RUN: diff -aub test_-a_-b_-c_-u.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_-a_-b_-c_-u.h.gcov test.h.gcov
+
+# Missing gcda file just gives 0 counts.
+RUN: llvm-cov test.c -gcda=no_such_gcda_file | diff -u test_no_gcda.output -
+RUN: diff -aub test_no_gcda.cpp.gcov test.cpp.gcov
+RUN: diff -aub test_no_gcda.h.gcov test.h.gcov
+
+# Invalid gcno file.
+RUN: not llvm-cov test.c -gcno=test_read_fail.gcno
+
+# Bad file checksum on gcda.
+RUN: not llvm-cov test.c -gcda=test_file_checksum_fail.gcda
-RUN: not llvm-cov -gcno=test_read_fail.gcno -gcda=test.gcda
+# Bad function checksum on gcda
+RUN: not llvm-cov test.c -gcda=test_func_checksum_fail.gcda
-XFAIL: powerpc64, s390x
+XFAIL: powerpc64, s390x, mips-, mips64-, sparc