llvm-project/llvm/tools/llvm-cov
Fangrui Song 4d7b194543 [llvm-cov gcov] Refactor counting and reporting
The current organization of FileInfo and its referenced utility functions of
(GCOVFile, GCOVFunction, GCOVBlock) is messy. Some members of FileInfo are just
copied from GCOVFile. FileInfo::print (.gcov output and --intermediate output)
is interleaved with branch statistics and computation of line execution counts.
--intermediate has to do redundant .gcov output to gather branch statistics.

This patch deletes lots of code and introduces a clearer work flow:

```
fn collectFunction
  for each block b
    for each line lineNum
      let line be LineInfo of the file on lineNum
      line.exists = 1
      increment function's lines & linesExec if necessary
      increment line.count
      line.blocks.push_back(&b)

fn collectSourceLine
  compute cycle counts
  count = incoming_counts + cycle_counts
  if line.exists
    ++summary->lines
    if line.count
      ++summary->linesExec

fn collectSource
  for each line
    call collectSourceLine

fn main
  for each function
    call collectFunction
    print function summary
  for each source file
    call collectSource
    print file summary
    annotate the source file with line execution counts
  if -i
    print intermediate file
```

The output order of functions and files now follows the original order in
.gcno files.
2020-09-13 23:00:59 -07:00
..
CMakeLists.txt
CodeCoverage.cpp CoverageFilters.h - reduce unnecessary includes to forward declarations. NFC. 2020-05-27 16:57:47 +01:00
CoverageExporter.h Revert "[llvm-cov] Add option to whitelist filenames" 2019-10-29 22:38:38 -07:00
CoverageExporterJson.cpp [llvm-cov] Prevent llvm-cov from using too many threads 2020-04-24 15:28:25 -04:00
CoverageExporterJson.h Revert "[llvm-cov] Add option to whitelist filenames" 2019-10-29 22:38:38 -07:00
CoverageExporterLcov.cpp [llvm-cov] Add support for -skip-functions to lcov 2020-01-22 12:49:00 -08:00
CoverageExporterLcov.h Revert "[llvm-cov] Add option to whitelist filenames" 2019-10-29 22:38:38 -07:00
CoverageFilters.cpp CoverageFilters.h - reduce unnecessary includes to forward declarations. NFC. 2020-05-27 16:57:47 +01:00
CoverageFilters.h Fix `-Wpedantic` warning. NFC. 2020-05-27 15:57:03 -04:00
CoverageReport.cpp [llvm-cov] Prevent llvm-cov from using too many threads 2020-04-24 15:28:25 -04:00
CoverageReport.h Revert "[llvm-cov] Add option to whitelist filenames" 2019-10-29 22:38:38 -07:00
CoverageSummaryInfo.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
CoverageSummaryInfo.h
CoverageViewOptions.h
LLVMBuild.txt
RenderingSupport.h
SourceCoverageView.cpp Revert "Remove redundant "std::move"s in return statements" 2020-02-10 07:07:40 -08:00
SourceCoverageView.h
SourceCoverageViewHTML.cpp Simplify string joins. NFCI. 2020-04-11 17:20:11 +02:00
SourceCoverageViewHTML.h
SourceCoverageViewText.cpp
SourceCoverageViewText.h
TestingSupport.cpp [Alignment][NFC] Remove unneeded llvm:: scoping on Align types 2019-09-27 12:54:21 +00:00
gcov.cpp [llvm-cov gcov] Refactor counting and reporting 2020-09-13 23:00:59 -07:00
llvm-cov.cpp