summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/CoverageReport.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[llvm-cov] Add option to whitelist filenames"Vlad Tsyrklevich2019-10-291-3/+3
| | | | | | This reverts commit bfed824b57d14e2ba98ddbaf1a1410cf04a3e279, the included test fails on many bots including the sanitier bots, e.g. in http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/36140
* [llvm-cov] Add option to whitelist filenamesVedant Kumar2019-10-291-3/+3
| | | | | | | | | Add the `-whitelist-filename-regex` option to restrict coverage reporting to file paths that match a whitelist regex. Patch by Michael Daniels! rdar://56720320
* Revert r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama2019-08-021-1/+1
| | | | | | | | operator<< This reverts commit r367649 in an attempt to unbreak Windows bots. llvm-svn: 367658
* Improve raw_ostream so that you can "write" colors using operator<<Rui Ueyama2019-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. raw_ostream supports ANSI colors so that you can write messages to the termina with colors. Previously, in order to change and reset color, you had to call `changeColor` and `resetColor` functions, respectively. So, if you print out "error: " in red, for example, you had to do something like this: OS.changeColor(raw_ostream::RED); OS << "error: "; OS.resetColor(); With this patch, you can write the same code as follows: OS << raw_ostream::RED << "error: " << raw_ostream::RESET; 2. Add a boolean flag to raw_ostream so that you can disable colored output. If you disable colors, changeColor, operator<<(Color), resetColor and other color-related functions have no effect. Most LLVM tools automatically prints out messages using colors, and you can disable it by passing a flag such as `--disable-colors`. This new flag makes it easy to write code that works that way. Differential Revision: https://reviews.llvm.org/D65564 llvm-svn: 367649
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-011-6/+6
| | | | | | | | | | | | | | | | We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46290 llvm-svn: 331272
* [llvm-cov] Implement -ignore-filename-regex= option for excluding source files.Max Moroz2018-04-091-3/+7
| | | | | | | | | | | | | | | | | | | Summary: The option is helpful for large projects where it's not feasible to specify sources which user would like to see in the report. Instead, it allows to black-list specific sources via regular expressions (e.g. now it's possible to skip all files that have "test" in its name). This also partially fixes https://bugs.llvm.org/show_bug.cgi?id=34277 Reviewers: vsk, morehouse, liaoyuke Reviewed By: vsk Subscribers: kcc, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D43907 llvm-svn: 329581
* [llvm-cov] Multi-threaded implementation of prepareFileReports method.Max Moroz2018-01-051-26/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Local testing has demonstrated a great speed improvement, compare the following: 1) Existing version: ``` $ time llvm-cov show -format=html -output-dir=report -instr-profile=... ... The tool has been launched: 00:00:00 Loading coverage data: 00:00:00 Get unique source files: 00:00:33 Creating an index out of the source files: 00:00:34 Going into prepareFileReports: 00:00:34 Going to emit summary information for each file: 00:28:55 <-- 28:21 min! Going to emit links to files with no function: 00:28:55 Launching 32 threads for generating HTML files: 00:28:55 real 37m43.651s user 112m5.540s sys 7m39.872s ``` 2) Multi-threaded version with 32 CPUs: ``` $ time llvm-cov show -format=html -output-dir=report -instr-profile=... ... The tool has been launched: 00:00:00 Loading coverage data: 00:00:00 Get unique source files: 00:00:38 Creating an index out of the source files: 00:00:40 Going into prepareFileReports: 00:00:40 Preparing file reports using 32 threads: 00:00:40 # Creating thread tasks for the following number of files: 16422 Going to emit summary information for each file: 00:01:57 <-- 1:17 min! Going to emit links to files with no function: 00:01:58 Launching 32 threads for generating HTML files: 00:01:58 real 11m2.044s user 134m48.124s sys 7m53.388s ``` Reviewers: vsk, morehouse Reviewed By: vsk Subscribers: Dor1s, llvm-commits, kcc Differential Revision: https://reviews.llvm.org/D41206 llvm-svn: 321871
* Remove redundant includes from tools.Michael Zolotukhin2017-12-131-1/+0
| | | | llvm-svn: 320631
* [llvm-cov] Generate "report" for given source paths if sources are specified.Max Moroz2017-10-131-1/+6
| | | | | | | | | | | | | | | | Summary: Documentation says that user can specify sources for both "show" and "report" commands. "Show" command respects specified sources, but "report" does not. It is useful to have both "show" and "report" generated for specified sources. Also added tests to for both commands with sources specified. Reviewers: vsk, kcc Reviewed By: vsk Differential Revision: https://reviews.llvm.org/D38860 llvm-svn: 315685
* [llvm-cov] Hide files with no coverage from the index when filtering by nameSean Eveson2017-10-031-4/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D38457 llvm-svn: 314782
* [llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson2017-09-281-4/+11
| | | | | | | | | | | Before this change using any of the -name*= command line options with an output directory would result in a single file (functions.txt/functions.html) containing the coverage for those specific functions. Now you get the same directory structure as when not using any -name*= options. Differential Revision: https://reviews.llvm.org/D38280 llvm-svn: 314396
* Revert "[llvm-cov] Create directory structure when filtering using -name*= ↵Sean Eveson2017-09-271-11/+4
| | | | | | | | options" Test failures. llvm-svn: 314314
* [llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson2017-09-271-4/+11
| | | | | | | | | | | Before this change using any of the -name*= command line options with an output directory would result in a single file (functions.txt/functions.html) containing the coverage for those specific functions. Now you get the same directory structure as when not using any -name*= options. Differential Revision: https://reviews.llvm.org/D38280 llvm-svn: 314310
* [llvm-cov] Make report metrics agree with line exec counts, fixes PR34615Vedant Kumar2017-09-191-2/+2
| | | | | | | | | Use the same logic as the line-oriented coverage view to determine the number of covered lines in a function. Fixes llvm.org/PR34615. llvm-svn: 313604
* [llvm-cov] Make some summary info fields private. NFC.Vedant Kumar2017-09-151-25/+26
| | | | | | | | There's a bug in the way the line and region summary objects are merged. It would have been less likely to occur if those objects kept some data private. llvm-svn: 313416
* [llvm-cov] Remove a redundant field. NFC.Vedant Kumar2017-09-151-4/+8
| | | | | | | | | | The "NotCovered" fields in the region and line summary structs are redundant. We should remove them to make the code clearer. As a follow-up, the "NotCovered" entries should be removed from the reports as well. llvm-svn: 313415
* [llvm-cov] Allow hiding instantiation/region coverage from summary tablesEli Friedman2017-09-111-34/+44
| | | | | | | | | | | | | Region coverage is difficult to explain without going deep into how coverage is implemented. Instantiation coverage is easier to explain, but probably not useful in most cases (templates don't exist in C, and most C++ code contains relatively few templates). This patch adds the options "-show-region-summary" and "-show-instantiation-summary" to allow hiding those columns. "-show-instantiation-summary" is turned off by default. llvm-svn: 312969
* [llvm-cov] Fix a lifetime issueVedant Kumar2017-09-081-5/+9
| | | | | | | This fixes an issue where a std::string was moved to a constructor which accepted a StringRef. llvm-svn: 312816
* [llvm-cov] Rearrange entries in report index.Eli Friedman2017-08-091-2/+16
| | | | | | | | | | | | | | Files which don't contain any functions are likely useless; don't include them in the main table. Put the links at the bottom of the page, in case someone wants to figure out coverage for code inside a macro. Not sure if this is the best solution, but it seems like an improvement. Differential Revision: https://reviews.llvm.org/D36298 llvm-svn: 310518
* [Coverage] Add an API to retrive all instantiations of a function (NFC)Vedant Kumar2017-08-021-18/+12
| | | | | | | | | | | | | | | | | | | | | | | | | The CoverageMapping::getInstantiations() API retrieved all function records corresponding to functions with more than one instantiation (e.g template functions with multiple specializations). However, there was no simple way to determine *which* function a given record was an instantiation of. This was an oversight, since it's useful to aggregate coverage information over all instantiations of a function. llvm-cov works around this by building a mapping of source locations to instantiation sets, but this duplicates logic that libCoverage already has (see FunctionInstantiationSetCollector). This change adds a new API, CoverageMapping::getInstantiationGroups(), which returns a list of InstantiationGroups. A group contains records for each instantiation of some particular function, and also provides utilities to get the total execution count within the group, the source location of the common definition, etc. This lets removes some hacky logic in llvm-cov by reusing FunctionInstantiationSetCollector and makes the CoverageMapping API friendlier for other clients. llvm-svn: 309904
* Use the new member accessors of llvm::enumerate.Zachary Turner2017-03-131-3/+3
| | | | | | | The value_type is no longer a struct, it's a class whose members you have to access via a method. llvm-svn: 297635
* [llvm-cov] Strip redundant path components from filenames (fix PR31982)Vedant Kumar2017-02-231-14/+44
| | | | | | | | | Instead of stripping the longest common prefix off of the filenames in a report, strip out the longest chain of redundant path components. This fixes the case in PR31982, where there are two files with the same prefix, and stripping out the LCP makes things less intelligible. llvm-svn: 296029
* [llvm-cov] Demangle symbols in function summaries (fixes PR31394)Vedant Kumar2017-02-051-4/+7
| | | | llvm-svn: 294136
* [llvm-cov] Avoid 0% when reporting something that's 0/0Alex Lorenz2016-11-211-16/+28
| | | | | | | | | | | | | This commit makes llvm-cov avoid showing 0% (0/0) coverage for things like file function coverage, etc. in reports and HTML output. This can happen for files like headers that have macros but no functions. This commit makes llvm-cov report - (0/0) instead. rdar://29246480 Differential Revision: https://reviews.llvm.org/D26615 llvm-svn: 287539
* [llvm-cov] Silence a warning from the MSVC runtime (NFC)Vedant Kumar2016-09-261-4/+6
| | | | | | | | | | | | | | | | | | | Rework getLongestCommonPrefixLen() so that it doesn't access string null terminators. The old version with std::mismatch would do this: | v Strings[0] = ['a', nil] Strings[1] = ['a', 'a', nil] ^ | This should silence a warning from the MSVC runtime (PR30515). As before, I tested this out by preparing a coverage report for FileCheck. Thanks to Yaron Keren for the report! llvm-svn: 282422
* [llvm-cov] Get rid of all invalid filename referencesVedant Kumar2016-09-231-5/+7
| | | | | | | | | | | | | | We used to append filenames into a vector of std::string, and then append a reference to each string into a separate vector. This made it easier to work with the getUniqueSourceFiles API. But it's buggy. std::string has a small-string optimization, so you can't expect to capture a reference to one if you're copying it into a growing vector. Add a test that triggers this invalid reference to std::string scenario, and kill the issue with fire by just using ArrayRef<std::string> everywhere. llvm-svn: 282281
* [llvm-cov] Make a helper method static for re-use (NFC)Vedant Kumar2016-09-191-3/+4
| | | | llvm-svn: 281876
* [llvm-cov] Track function and instantiation coverage separatelyVedant Kumar2016-09-191-8/+41
| | | | | | | | | | | | | | | | | | | | These are distinct statistics which are useful to look at separately. Example: say you have a template function "foo" with 5 instantiations and only 3 of them are covered. Then this contributes (1/1) to the total function coverage and (3/5) to the total instantiation coverage. I.e, the old "Function Coverage" column has been renamed to "Instantiation Coverage", and the new "Function Coverage" aggregates information from the various instantiations of a function. One benefit of making this switch is that the Line and Region coverage columns will start making sense. Let's continue the example and assume that the 5 instantiations of "foo" cover {2, 4, 6, 8, 10} out of 10 lines respectively. The new line coverage for "foo" is (10/10), not (30/50). The old scenario got confusing because we'd report that there were more lines in a file than what was actually possible. llvm-svn: 281875
* [llvm-cov] Make 'adjustColumnWidths' do less workVedant Kumar2016-09-191-12/+23
| | | | | | | | | | | | This drops some redundant calls to get{UniqueSourceFiles, CoveredFunctions}. We can figure out the right column widths without re-doing this expensive work. This isn't NFC, but I don't want to check in another binary *.covmapping file with long filenames in it. I tested this locally on a project with some long filenames (FileCheck). llvm-svn: 281873
* [llvm-cov] Handle native paths correctly in the text indexVedant Kumar2016-09-091-1/+5
| | | | | | | | | | Treat filenames the same way in the text index as we do in the html index. This is a follow-up to r281008 (an attempt to unbreak the native_separators.c test on Windows). Patch by Maggie Yi! llvm-svn: 281062
* [llvm-cov] Add an API to prepare file reports (NFC)Vedant Kumar2016-09-091-17/+35
| | | | | | | | It would be nice to prepare file reports (using the CoverageReport API) without actually rendering them to the console. I plan on using this to flesh out the 'index' files in the coverage views. llvm-svn: 281009
* [llvm-cov] Drop the longest common filename prefix from summariesVedant Kumar2016-09-081-2/+20
| | | | | | | Remove the longest common prefix from filenames when printing coverage summaries. This makes them easier to compare. llvm-svn: 280895
* [llvm-cov] Use colors consistently in the summaryVedant Kumar2016-09-061-32/+32
| | | | | | | | Use the same color for counts and percentages. There doesn't seem to be a reason for them to be different, and the summary looks more consistent this way. llvm-svn: 280765
* [llvm-cov] Clean up the summary class, delete dead code (NFC)Vedant Kumar2016-09-061-54/+53
| | | | llvm-svn: 280764
* [llvm-cov] - Add the coverage of lines in the summary report.Ying Yi2016-07-221-4/+24
| | | | | | | | | | The llvm-cov ‘report' command displays a summary of the coverage of a binary file. The summary report currently only includes covered regions and covered functions. This patch adds the coverage of lines in the summary report. Differential Revision: https://reviews.llvm.org/D22569 llvm-svn: 276409
* [llvm-cov] Avoid copying file paths multiple times (NFC)Vedant Kumar2016-06-281-1/+1
| | | | llvm-svn: 274027
* [llvm-cov] Adjust column widths for function and file reportsVedant Kumar2015-10-211-9/+13
| | | | | | | | Previously, we only expanded function and filename column widths when rendering file reports. This commit makes the change for function reports as well. llvm-svn: 250900
* [llvm-cov] Disable name and path truncationVedant Kumar2015-09-141-6/+21
| | | | | | | | | | | Change the output of llvm-cov s.t it does not truncate function names and file paths when printing coverage reports. Differential Revision: http://reviews.llvm.org/D12647 rdar://22531141 llvm-svn: 247635
* llvm-cov: Actually use the command line arguments when reportingJustin Bogner2015-02-141-2/+3
| | | | | | | | This code didn't really make sense as is. If a filename is passed in, the user obviously wants the coverage *for that file*, not *for everything*. llvm-svn: 229217
* llvm-cov: Simplify coverage reports, fixing PR22575 in the processJustin Bogner2015-02-141-12/+25
| | | | | | | | | | | | | | PR22575 occurred because we were unsafely storing references into a std::vector. If the vector moved because it grew, we'd be left iterating through garbage memory. This avoids the issue by simplifying the logic to gather coverage information as we go, rather than storing it and iterating over it. I'm relying on the existing tests showing that this is semantically NFC, since it's difficult to hit the issue this fixes without relatively large covered programs. llvm-svn: 229215
* [cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth2015-01-141-1/+1
| | | | | | | | | | | utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
* llvm-cov/CoverageReport.cpp: Quick fix for msvcrt, since width specifier "z" ↵NAKAMURA Takumi2014-10-011-12/+12
| | | | | | | | is unavailable. Note, mingw uses its own printf instead of msvcrt. llvm-svn: 218723
* llvm-cov: Use the number of executed functions for the function coverage metric.Alex Lorenz2014-09-301-4/+5
| | | | | | | | This commit fixes llvm-cov's function coverage metric by using the number of executed functions instead of the number of fully covered functions. Differential Revision: http://reviews.llvm.org/D5196 llvm-svn: 218672
* llvm-cov: add code coverage tool that's based on coverage mapping format and ↵Alex Lorenz2014-08-221-0/+201
clang's pgo. This commit expands llvm-cov's functionality by adding support for a new code coverage tool that uses LLVM's coverage mapping format and clang's instrumentation based profiling. The gcov compatible tool can be invoked by supplying the 'gcov' command as the first argument, or by modifying the tool's name to end with 'gcov'. Differential Revision: http://reviews.llvm.org/D4445 llvm-svn: 216300
OpenPOWER on IntegriCloud