1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00
llvm-mirror/test/tools/llvm-cov/range_based_for.cpp
Calixte Denizet 498f8e9f26 [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

30 lines
1.1 KiB
C++

// Make sure that compiler-added local variables (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/range_based_for.gc* .
// RUN: llvm-cov gcov range_based_for.cpp | FileCheck %s --check-prefix=STDOUT
// STDOUT: File 'range_based_for.cpp'
// STDOUT: Lines executed:100.00% of 5
// STDOUT: range_based_for.cpp:creating 'range_based_for.cpp.gcov'
// RUN: FileCheck %s --check-prefix=GCOV < %t/range_based_for.cpp.gcov
// GCOV: -: 0:Runs:1
// GCOV: -: 0:Programs:1
int main(int argc, const char *argv[]) { // GCOV: 1: [[@LINE]]:int main(
int V[] = {1, 2}; // GCOV: 1: [[@LINE]]: int V[]
for (int &I : V) { // GCOV: 5: [[@LINE]]: for (
} // GCOV: 2: [[@LINE]]: }
return 0; // GCOV: 1: [[@LINE]]: return
} // GCOV: -: [[@LINE]]:}
// llvm-cov doesn't work on big endian yet
// XFAIL: powerpc-, powerpc64-, s390x, mips-, mips64-, sparc