summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cov/CodeCoverage.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Refactor ExecuteAndWait to take StringRefs.Zachary Turner2018-06-121-6/+5
| | | | | | | | | | | | | | | | | | | This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better. llvm-svn: 334518
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-011-17/+17
| | | | | | | | | | | | | | | | 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-5/+22
| | | | | | | | | | | | | | | | | | | 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] Prevent llvm-cov from hanging when a symblink doesn't exist.Max Moroz2018-04-051-4/+8
| | | | | | | | | | | | | | | | | | | | Summary: Previous code hangs indefinitely when trying to iterate through a symbol link file that points to an non-exist directory. This change fixes the bug to make the addCollectedPath function exit ealier and print out correct warning messages. Patch by Yuke Liao (@liaoyuke). Reviewers: Dor1s, vsk Reviewed By: vsk Subscribers: bruno, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D44960 llvm-svn: 329338
* [llvm-cov] Multi-threaded implementation of prepareFileReports method.Max Moroz2018-01-051-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [llvm-cov] Refactor "export" command implementation and add support for SOURCES.Max Moroz2018-01-041-16/+22
| | | | | | | | | | | | | | Summary: Define an interface for Exporter + split JSON exporter into .h and .cpp. Reviewers: vsk, morehouse Reviewed By: vsk Subscribers: llvm-commits, Dor1s, kcc Differential Revision: https://reviews.llvm.org/D41600 llvm-svn: 321815
* Avoid int to string conversion in Twine or raw_ostream contexts.Benjamin Kramer2017-12-281-2/+3
| | | | | | Some output changes from uppercase hex to lowercase hex, no other functionality change intended. llvm-svn: 321526
* [llvm-cov] Add an option for "export" command to emit only file summary data.Max Moroz2017-12-111-0/+5
| | | | | | | | | | | | | | Summary: That allows to get the same data as produced by "llvm-cov report", but in JSON format, which is better for further processing by end users. Reviewers: vsk Reviewed By: vsk Differential Revision: https://reviews.llvm.org/D41085 llvm-svn: 320435
* [llvm-cov] Generate "report" for given source paths if sources are specified.Max Moroz2017-10-131-1/+4
| | | | | | | | | | | | | | | | 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] Fix showing title when filtering and not outputting to a directorySean Eveson2017-10-041-1/+1
| | | | | | Differential Revision: https://reviews.llvm.org/D38507 llvm-svn: 314885
* [llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson2017-09-281-31/+46
| | | | | | | | | | | 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-46/+31
| | | | | | | | options" Test failures. llvm-svn: 314314
* [llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson2017-09-271-31/+46
| | | | | | | | | | | 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] Warn if -show-functions is used without query filesVedant Kumar2017-09-251-2/+9
| | | | | | | | | | llvm-cov's report mode does not print any output when -show-functions is specified and no source files are specified. This can be surprising, so the tool should at least print out an error message when this happens. rdar://problem/34636859 llvm-svn: 314175
* [Support] Rename tool_output_file to ToolOutputFile, NFCReid Kleckner2017-09-231-2/+2
| | | | | | | This class isn't similar to anything from the STL, so it shouldn't use the STL naming conventions. llvm-svn: 314050
* [llvm-cov] Improve error messaging for function mismatchesVedant Kumar2017-09-211-1/+15
| | | | | | | | | Passing "-dump" to llvm-cov will now print more detailed information about function hash and counter mismatches. This should make it easier to debug *.profdata files which contain incorrect records, and to debug other scenarios where coverage goes missing due to mismatch issues. llvm-svn: 313853
* [llvm-cov] Make report metrics agree with line exec counts, fixes PR34615Vedant Kumar2017-09-191-1/+1
| | | | | | | | | 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
* Convenience/safety fix for llvm::sys::Execute(And|No)WaitAlexander Kornienko2017-09-131-4/+1
| | | | | | | | | | | | | | | | | | | | Summary: Change the type of the Redirects parameter of llvm::sys::ExecuteAndWait, ExecuteNoWait and other APIs that wrap them from `const StringRef **` to `ArrayRef<Optional<StringRef>>`, which is safer and simplifies the use of these APIs (no more local StringRef variables just to get a pointer to). Corresponding clang changes will be posted as a separate patch. Reviewers: bkramer Reviewed By: bkramer Subscribers: vsk, llvm-commits Differential Revision: https://reviews.llvm.org/D37563 llvm-svn: 313155
* [llvm-cov] Allow hiding instantiation/region coverage from summary tablesEli Friedman2017-09-111-0/+12
| | | | | | | | | | | | | 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-1/+2
| | | | | | | This fixes an issue where a std::string was moved to a constructor which accepted a StringRef. llvm-svn: 312816
* [llvm-cov] Unify region marker placement between text/html modesVedant Kumar2017-09-081-1/+0
| | | | | | | | | | | | Make sure that the text and html emitters always emit the same set of region markers, and avoid emitting redundant markers for line segments which don't end on the line they start on. This is related to D35925, and depends on D36014 Differential Revision: https://reviews.llvm.org/D36020 llvm-svn: 312813
* [llvm-cov] Read in function names for filtering from a text file.Sean Eveson2017-08-311-1/+22
| | | | | | | | | | | | | | Summary: Add a -name-whitelist option, which behaves in the same way as -name, but it reads in multiple function names from the given input file(s). Reviewers: vsk Reviewed By: vsk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37111 llvm-svn: 312227
* [llvm-cov] Add an option which maps the location of source directories on ↵Sean Eveson2017-08-141-44/+77
| | | | | | | | | | | | | | | | | | | another machine to your local copies Summary: This patch adds the -path-equivalence option (example: llvm-cov show -path-equivalence=/origin/path,/local/path) which maps the source code path from one machine to another when using `llvm-cov show`. This is similar to the -filename-equivalence option, but doesn't require you to specify all the source files on the command line. This allows you to generate the coverage data on one machine (e.g. in a CI system), and then use llvm-cov on another machine where you have the same code base on a different path. Reviewers: vsk Reviewed By: vsk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D36391 llvm-svn: 310827
* [llvm-cov] NFC: make_unique-ify two allocationsVedant Kumar2017-08-041-4/+4
| | | | llvm-svn: 310011
* [Coverage] Add an API to retrive all instantiations of a function (NFC)Vedant Kumar2017-08-021-16/+22
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [llvm-cov] Respect the value of the -show-instantiations optionVedant Kumar2017-08-021-1/+3
| | | | | | | Make `-show-instantiations=false` actually skip displaying instantiation sub-views, instead of simply ignoring the option. llvm-svn: 309903
* [llvm-cov] Allow specifying distinct architectures for each loaded binaryVedant Kumar2017-08-011-9/+16
| | | | | | | | | | | The coverage tool needs to know which slice to look at when it's handed a universal binary. Some projects need to look at aggregate coverage reports for a variety of slices in different binaries: this patch adds support for these kinds of projects to llvm-cov. rdar://problem/33579007 llvm-svn: 309747
* [llvm-cov] Add a cl::opt to control the number of threadsVedant Kumar2017-07-111-4/+15
| | | | | | | | | | When an output directory is specified, llvm-cov spawns some threads to speed up the process of writing out file reports. Add an option which allows users to control how many threads llvm-cov uses. A CommandGuide.rst update + test is included. llvm-svn: 307609
* [llvm-cov] Error-out when an unsupported format is used (PR32087)Vedant Kumar2017-02-281-1/+8
| | | | llvm-svn: 296487
* [llvm-cov] Respect Windows line endings when parsing demangled symbols.Igor Kudrin2017-02-191-1/+3
| | | | | | Differential Revision: https://reviews.llvm.org/D30096 llvm-svn: 295605
* [llvm-cov] Don't show function summaries when filtering by filename (fixes ↵Vedant Kumar2017-02-051-1/+5
| | | | | | PR31395) llvm-svn: 294137
* [llvm-cov] Demangle symbols in function summaries (fixes PR31394)Vedant Kumar2017-02-051-1/+1
| | | | llvm-svn: 294136
* [llvm-cov] Refactor logic for storing demangled symbols, NFCVedant Kumar2017-02-051-15/+6
| | | | llvm-svn: 294135
* [llvm-cov] Fix a comment, NFCVedant Kumar2017-02-051-1/+1
| | | | llvm-svn: 294134
* Apply clang-tidy's 'performance-faster-string-find' check to LLVM.Benjamin Kramer2016-11-301-1/+1
| | | | | | No functionality change intended. llvm-svn: 288235
* Fix spelling mistakes in Tools/Tests comments. NFC.Simon Pilgrim2016-11-201-1/+1
| | | | | | Identified by Pedro Giffuni in PR27636. llvm-svn: 287489
* [llvm-cov] Don't use colored output until we know it's supportedVedant Kumar2016-10-251-2/+2
| | | | | | | | | CodeCoverageTool::error() depends on CoverageViewOptions::Colors being initialized. Should fix: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/56 llvm-svn: 285103
* [llvm-cov] Add support for loading coverage from multiple objectsVedant Kumar2016-10-251-9/+23
| | | | | | Differential Revision: https://reviews.llvm.org/D25086 llvm-svn: 285088
* [llvm-cov] Do not print out the filename of the object fileVedant Kumar2016-10-251-10/+2
| | | | | | | | | When we load coverage data from multiple objects, we don't have a way to attribute a source object to a function record. Printing out the object filename next to the source filename is already not very useful: soon, it'll actually become misleading. Stop printing out the filename now. llvm-svn: 285043
* Remove TimeValue usage from llvm/SupportPavel Labath2016-10-241-1/+2
| | | | | | | | | | | | | | | | | Summary: This is a follow-up to D25416. It removes all usages of TimeValue from llvm/Support library (except for the actual TimeValue declaration), and replaces them with appropriate usages of std::chrono. To facilitate this, I have added small utility functions for converting time points and durations into appropriate OS-specific types (FILETIME, struct timespec, ...). Reviewers: zturner, mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25730 llvm-svn: 284966
* [llvm-cov] Don't spawn a thread unless ThreadCount > 1Vedant Kumar2016-10-191-27/+39
| | | | | | | | | | | | Initializing a ThreadPool with ThreadCount = 1 spawns a thread even though we don't need to. This is at least slower than it needs to be, and at worst may somehow be exacerbating PR30735 (llvm-cov times out on ARM bots). As a follow-up, I'll try to add logic to llvm::ThreadPool to avoid spawning a thread when ThreadCount = 1. llvm-svn: 284621
* Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini2016-10-081-2/+1
| | | | | | | | | | | | | | | template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671
* [llvm-cov] Factor out logic to remove unmapped inputs (NFC)Vedant Kumar2016-09-231-5/+13
| | | | llvm-svn: 282286
* [llvm-cov] Filter away source files that aren't in the coverage mappingVedant Kumar2016-09-231-3/+19
| | | | | | | | ... so that they don't show up in the index. This came up because polly contains a .git directory and some other unmapped input in its source dir. llvm-svn: 282282
* [llvm-cov] Get rid of all invalid filename referencesVedant Kumar2016-09-231-13/+9
| | | | | | | | | | | | | | 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] Document some fields in a class (NFC)Vedant Kumar2016-09-221-4/+15
| | | | llvm-svn: 282203
* [llvm-cov] Add the ability to specify directories of input source filesVedant Kumar2016-09-221-10/+56
| | | | | | | | | We've supported restricting coverage reports to a set of files for a long time. Add support for being able to restrict by entire directories. I suppose this supersedes D20803. llvm-svn: 282202
* [llvm-cov] Demangle names for hidden instantiation viewsVedant Kumar2016-09-201-3/+4
| | | | llvm-svn: 282020
* [llvm-cov] Hide instantiation views for unexecuted functionsVedant Kumar2016-09-151-14/+16
| | | | | | | | Copying in the full text of the function doesn't help at all when we already know that it's never executed. Just say that it's unexecuted -- the relevant source text has already been printed. llvm-svn: 281589
* [llvm-cov] Emit a summary in the report directory's indexVedant Kumar2016-09-091-1/+1
| | | | | | | | llvm-cov writes out an index file in '-output-dir' mode, albeit not a very informative one. Try to fix that by using the CoverageReport API to include some basic summary information in the index file. llvm-svn: 281011
OpenPOWER on IntegriCloud