summaryrefslogtreecommitdiff
path: root/tools/llvm-cov
AgeCommit message (Collapse)Author
2017-12-28Avoid int to string conversion in Twine or raw_ostream contexts.Benjamin Kramer
Some output changes from uppercase hex to lowercase hex, no other functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321526 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13Remove redundant includes from tools.Michael Zolotukhin
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320631 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-11[llvm-cov] Add an option for "export" command to emit only file summary data.Max Moroz
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320435 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09[llvm-cov] Don't render empty region marker linesVedant Kumar
This fixes an issue where llvm-cov prints an empty line, thinking it needs to display region markers, when it actually doesn't. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317762 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09[Coverage] Use the wrapped segment when a line has entry segmentsVedant Kumar
We've worked around bugs in the frontend by ignoring the count from wrapped segments when a line has at least one region entry segment. Those frontend bugs are now fixed, so it's time to regenerate the checked-in covmapping files and remove the workaround. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317761 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-03GCOV: Move GCOV from IR & Support into ProfileData to fix layeringDavid Blaikie
This class was split between libIR and libSupport, which breaks under modular code generation. Move it into the one library that uses it, ProfileData, to resolve this issue. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317366 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-24[llvm-cov] Use a stable sort on sub-viewsVedant Kumar
We need to use a stable sort on instantiation and expansion sub-views to produce consistent output. Fortunately, we've gotten lucky and the tests have checks for the stable order. This is needed to unblock D39245. Once that lands, we'll have better test coverage for sort non-determinism. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316490 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-18[llvm-cov] Move LineCoverageIterator to libCoverage. NFC.Vedant Kumar
LineCoverageIterator makes it easy for clients of coverage data to determine line execution counts for a file or function. The coverage iteration logic is tricky enough that it really pays not to have multiple copies of it. Hopefully having just one implementation in LLVM will make the iteration logic easier to test, reuse, and update. This commit is NFC but I've added a unit test to go along with it just because it's easy to do now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316141 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-18[llvm-cov] Use the coverage namespace. NFC.Vedant Kumar
This is a simple code cleanup. It will facilitate moving LineCoverageIterator to libCoverage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316140 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-18[llvm-cov] Suppress sub-line highlights in simple casesVedant Kumar
llvm-cov tends to highlight too many regions because its policy is to highlight all region entry segments. This can look confusing to users: not all region entry segments are interesting and deserve highlighting. Emitting these highlights only when the region count differs from the line count is a more user-friendly policy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316109 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-18[llvm-cov] Pass LineCoverageStats in SourceCoverageView. NFC.Vedant Kumar
Instead of copying around the wrapped segment and the list of line segments, just pass a reference to a LineCoverageStats object. This simplifies the interface. It also makes an upcoming change to suppress distracting highlights possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316108 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-18[llvm-cov] Highlight gaps in consecutive uncovered regionsVedant Kumar
llvm-cov typically doesn't highlight gap segments, but it should if the gap occurs after an uncovered region in order to preserve continuity. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316107 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-17[llvm-cov] Add one correction to r315960 (PR34962)Vedant Kumar
In r315960, I accidentally assumed that the first line segment is guaranteed to be the non-gap region entry segment (given that one is present). It can actually be any segment on the line, and the test I checked in demonstrates that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315963 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-16[llvm-cov] Remove workaround in line execution count calculation (PR34962)Vedant Kumar
Gap areas make it possible to correctly determine when to use counts from deferred regions. Before gap areas were introduced, llvm-cov needed to use a heuristic to do this: it ignored counts from segments that start, but do not end, on a line. This heuristic breaks down on a simple example (see PR34962). This patch removes the heuristic and picks counts from any region entry segment which isn't a gap area. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315960 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-14[llvm-cov] Factor out logic to iterate over line coverage stats (NFC)Vedant Kumar
There were two copies of the logic needed to construct a line stats object for each line in a range: this patch brings it down to one. In the future, this will make it easier for IDE clients to display coverage in-line in source editors. To do that, we just need to move the new LineCoverageIterator class to libCoverage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315789 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-13[llvm-cov] Generate "report" for given source paths if sources are specified.Max Moroz
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315685 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-04[llvm-cov] Fix showing title when filtering and not outputting to a directorySean Eveson
Differential Revision: https://reviews.llvm.org/D38507 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314885 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-03[llvm-cov] Hide files with no coverage from the index when filtering by nameSean Eveson
Differential Revision: https://reviews.llvm.org/D38457 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314782 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-28[llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314396 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27Revert "[llvm-cov] Create directory structure when filtering using -name*= ↵Sean Eveson
options" Test failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314314 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27[llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314310 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-27[llvm-cov] Improve const-correctness of filters. NFC.Sean Eveson
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314281 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-25[llvm-cov] Warn if -show-functions is used without query filesVedant Kumar
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314175 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-25Add section headers to SpecialCaseListsVlad Tsyrklevich
Summary: Sanitizer blacklist entries currently apply to all sanitizers--there is no way to specify that an entry should only apply to a specific sanitizer. This is important for Control Flow Integrity since there are several different CFI modes that can be enabled at once. For maximum security, CFI blacklist entries should be scoped to only the specific CFI mode(s) that entry applies to. Adding section headers to SpecialCaseLists allows users to specify more information about list entries, like sanitizer names or other metadata, like so: [section1] fun:*fun1* [section2|section3] fun:*fun23* The section headers are regular expressions. For backwards compatbility, blacklist entries entered before a section header are put into the '[*]' section so that blacklists without sections retain the same behavior. SpecialCaseList has been modified to also accept a section name when matching against the blacklist. It has also been modified so the follow-up change to clang can define a derived class that allows matching sections by SectionMask instead of by string. Reviewers: pcc, kcc, eugenis, vsk Reviewed By: eugenis, vsk Subscribers: vitalybuka, llvm-commits Differential Revision: https://reviews.llvm.org/D37924 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314170 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-23[Support] Rename tool_output_file to ToolOutputFile, NFCReid Kleckner
This class isn't similar to anything from the STL, so it shouldn't use the STL naming conventions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314050 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-21[llvm-cov] Improve error messaging for function mismatchesVedant Kumar
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313853 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-19[llvm-cov] Make report metrics agree with line exec counts, fixes PR34615Vedant Kumar
Use the same logic as the line-oriented coverage view to determine the number of covered lines in a function. Fixes llvm.org/PR34615. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313604 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18[Coverage] Use gap regions to select better line exec countsVedant Kumar
After clang started emitting deferred regions (r312818), llvm-cov has had a hard time picking reasonable line execuction counts. There have been one or two generic improvements in this area (e.g r310012), but line counts can still report coverage for whitespace instead of code (llvm.org/PR34612). To fix the problem: * Introduce a new region kind so that frontends can explicitly label gap areas. This is done by changing the encoding of the columnEnd field of MappingRegion. This doesn't substantially increase binary size, and makes it easy to maintain backwards-compatibility. * Don't set the line count to a count from a gap area, unless the count comes from a wrapped segment. * Don't highlight gap areas as uncovered. Fixes llvm.org/PR34612. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313597 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18[llvm-cov] Simplify code to find the first uncovered segment. NFC.Vedant Kumar
Now that that segment builder is guaranteed to produce segments in sorted order, we don't need a linear scan to get the right result. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313595 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-15[llvm-cov] Fix a bot failure due to r313417Vedant Kumar
There's a type mismatch issue with the arguments to a call to std::min introduced in r313417. http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/11174 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313422 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-15[llvm-cov] Avoid over-counting covered lines and regionsVedant Kumar
* Fix an unsigned integer overflow in the logic that computes the number of uncovered lines in a function. * When aggregating region and line coverage summaries, take into account that different instantiations may have a different number of regions. The new test case provides test coverage for both bugs. I also verified this change by preparing a coverage report for a stage2 build of llc -- the new assertions should detect any outstanding over-counting bugs. Fixes PR34613. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313417 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-15[llvm-cov] Make some summary info fields private. NFC.Vedant Kumar
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313416 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-15[llvm-cov] Remove a redundant field. NFC.Vedant Kumar
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313415 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-13Convenience/safety fix for llvm::sys::Execute(And|No)WaitAlexander Kornienko
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313155 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-11[llvm-cov] Allow hiding instantiation/region coverage from summary tablesEli Friedman
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312969 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-11[llvm-cov] Don't attach exec counts to lines which start a skipped regionVedant Kumar
These lines by definition don't have an execution count. This is the final part of the fix for: https://bugs.llvm.org/show_bug.cgi?id=34166 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312955 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-08[llvm-cov] Fix a lifetime issueVedant Kumar
This fixes an issue where a std::string was moved to a constructor which accepted a StringRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312816 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-08[llvm-cov] Unify region marker placement between text/html modesVedant Kumar
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312813 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-31[llvm-cov] Read in function names for filtering from a text file.Sean Eveson
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312227 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-14[llvm-cov] Add an option which maps the location of source directories on ↵Sean Eveson
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310827 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-09[llvm-cov] Rearrange entries in report index.Eli Friedman
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310518 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-04[llvm-cov] Ignore unclosed line segments when setting line countsVedant Kumar
This patch makes a slight change to the way llvm-cov determines line execution counts. If there are multiple line segments on a line, the line count is the max count among the regions which start *and* end on the line. This avoids an issue posed by deferred regions which start on the same line as a terminated region, e.g: if (false) return; //< The line count should be 0, even though a new region //< starts at the semi-colon. foo(); Another change is that counts from line segments which don't correspond to region entries are considered. This enables the first change, and corrects an outstanding issue (see the showLineExecutionCounts.cpp test change). This is related to D35925. Testing: check-profile, llvm-cov lit tests Differential Revision: https://reviews.llvm.org/D36014 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310012 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-04[llvm-cov] NFC: make_unique-ify two allocationsVedant Kumar
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310011 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02[Coverage] Add an API to retrive all instantiations of a function (NFC)Vedant Kumar
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309904 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02[llvm-cov] Respect the value of the -show-instantiations optionVedant Kumar
Make `-show-instantiations=false` actually skip displaying instantiation sub-views, instead of simply ignoring the option. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309903 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-01[llvm-cov] Allow specifying distinct architectures for each loaded binaryVedant Kumar
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309747 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-11[llvm-cov] Add a cl::opt to control the number of threadsVedant Kumar
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307609 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-15[ProfileData] Unify getInstrProf*SectionName helpersVedant Kumar
This is a version of D32090 that unifies all of the `getInstrProf*SectionName` helper functions. (Note: the build failures which D32090 would have addressed were fixed with r300352.) We should unify these helper functions because they are hard to use in their current form. E.g we recently introduced more helpers to fix section naming for COFF files. This scheme doesn't totally succeed at hiding low-level details about section naming, so we should switch to an API that is easier to maintain. This is not an NFC commit because it fixes llvm-cov's testing support for COFF files (this falls out of the API change naturally). This is an area where we lack tests -- I will see about adding one as a follow up. Testing: check-clang, check-profile, check-llvm. Differential Revision: https://reviews.llvm.org/D32097 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300381 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13[Profile] PE binary coverage bug fixXinliang David Li
PR/32584 Differential Revision: https://reviews.llvm.org/D32023 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300277 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-13Use the new member accessors of llvm::enumerate.Zachary Turner
The value_type is no longer a struct, it's a class whose members you have to access via a method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297635 91177308-0d34-0410-b5e6-96231b3b80d8