[PATCH] D25985: [analyzer] Export coverage information from the analyzer.

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 07:18:35 PDT 2016


xazax.hun created this revision.
xazax.hun added reviewers: zaks.anna, NoQ, a.sidorin, dcoughlin.
xazax.hun added subscribers: cfe-commits, dkrupp, o.gyorgy, szepet.
xazax.hun set the repository for this revision to rL LLVM.

This patch adds a new option to export an optimistic basic block coverage from the static analyzer.

Example usage:

  clang++ --analyze -Xclang -analyzer-config -Xclang record-coverage=gcovfiles foo.cpp

Example output:

   -:0:Source:foo.cpp
  -:0:Runs:1
  -:0:Programs:1
  -:1:#include <iostream>
  -:2:
  -:3:int main() {
  -:4:  int i = 2;
  1:5:  ++i;
  1:6:  if (i) {
  1:7:    std::cout << "foo" << std::endl;
  1:8:  } else {
  -:9:    std::cout << "bar" << std::endl;
  -:10:  }
  -:11:}

It will generate a gcov file (sourcename.gcov) for each non system header source file in the directory that was given with the record-coverage option.

The gcov format is relatively easy to read, but HTML can be generated using gcovr:

  gcovr -g gcovfiles --html --html-details -r . -o example.html

In the future I also plan to contribute a python script that can aggregate the gcov files from different translation units into one folder.
Possible use cases:

- Get an overview about the coverage of the static analyzer on a given codebase.
- Collect ideas how to increase the coverage and test them.
- Evaluate possible cross translation unit coverage patterns.


Repository:
  rL LLVM

https://reviews.llvm.org/D25985

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/record-coverage.cpp
  test/Analysis/record-coverage.cpp.expected

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25985.75876.patch
Type: text/x-patch
Size: 8836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161026/3cce727f/attachment.bin>


More information about the cfe-commits mailing list