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() { 1:4: int i = 2; 1:5: ++i; 1:6: if (i) { 1:7: std::cout << "foo" << std::endl; -: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
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.
- Write rigorous tests about coverage.
Can this be a debug checker?