Files
clang-p2996/llvm/test/tools/llvm-cov/Inputs/test_paths.cpp.gcov
Calixte Denizet 0b1fe47e22 [gcov] Fix wrong line hit counts when multiple blocks are on the same line
Summary:
The goal of this patch is to have the same behaviour than gcc-gcov.
Currently the hit counts for a line is the sum of the counts for each block on that line.
The idea is to detect the cycles in the graph of blocks in using the algorithm by Hawick & James.
The count for a cycle is the min of the counts for each edge in the cycle.
Once we've the count for each cycle, we can sum them and add the transition counts of those cycles.

Fix both https://bugs.llvm.org/show_bug.cgi?id=38065 and https://bugs.llvm.org/show_bug.cgi?id=38066

Reviewers: marco-c, davidxl

Reviewed By: marco-c

Subscribers: vsk, lebedev.ri, sylvestre.ledru, dblaikie, llvm-commits

Differential Revision: https://reviews.llvm.org/D49659

llvm-svn: 342657
2018-09-20 16:09:30 +00:00

80 lines
2.4 KiB
Plaintext

-: 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() {
9: 33: for (int ii = 0; ii < 2; ii++)
18: 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:
33: 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;
12884901891: 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:}