Commit Graph

231 Commits

Author SHA1 Message Date
Benjamin Kramer
bf60ce0ebd Apply clang-tidy's 'performance-faster-string-find' check to LLVM.
No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288235 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-30 10:01:11 +00:00
Alex Lorenz
c636d7a9a3 [llvm-cov] Avoid 0% when reporting something that's 0/0
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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287539 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-21 14:00:04 +00:00
Simon Pilgrim
84354d97d5 Fix spelling mistakes in Tools/Tests comments. NFC.
Identified by Pedro Giffuni in PR27636.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287489 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20 13:31:13 +00:00
Vedant Kumar
f13ebed41c [llvm-cov] Turn line numbers in html reports into clickable links
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285853 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-02 19:44:13 +00:00
Benjamin Kramer
bf85e05280 Remove duplicated default move ctors/move assign. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285302 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-27 15:23:44 +00:00
Vedant Kumar
1fc13ff445 [llvm-cov] Don't use colored output until we know it's supported
CodeCoverageTool::error() depends on CoverageViewOptions::Colors being
initialized. Should fix:

  http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/56

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285103 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 19:52:57 +00:00
Vedant Kumar
d4998ec16b [llvm-cov] Add support for loading coverage from multiple objects
Differential Revision: https://reviews.llvm.org/D25086

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285088 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 17:40:55 +00:00
Vedant Kumar
5b5c5e7555 [llvm-cov] Do not print out the filename of the object file
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285043 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-25 00:08:33 +00:00
Pavel Labath
2864c2ae90 Remove TimeValue usage from llvm/Support
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284966 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-24 10:59:17 +00:00
Vedant Kumar
4c50ebb18b [llvm-cov] Don't spawn a thread unless ThreadCount > 1
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 17:55:44 +00:00
Vedant Kumar
d05e76c71d [Coverage] Delete some copy constructors (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284064 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-12 22:27:49 +00:00
Mehdi Amini
3ffe113e11 Turn cl::values() (for enum) from a vararg function to using C++ variadic 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283671 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 19:41:06 +00:00
Vedant Kumar
64f3b51479 [llvm-cov] Silence a warning from the MSVC runtime (NFC)
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282422 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-26 17:57:13 +00:00
Vedant Kumar
3de4fb3563 [llvm-cov] Factor out logic to remove unmapped inputs (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282286 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-23 20:13:41 +00:00
Vedant Kumar
daacf3c8ba [llvm-cov] Filter away source files that aren't in the coverage mapping
... 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282282 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-23 18:57:35 +00:00
Vedant Kumar
fd066351a5 [llvm-cov] Get rid of all invalid filename references
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282281 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-23 18:57:32 +00:00
Vedant Kumar
c36f315edc [llvm-cov] Minor cleanup. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282280 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-23 18:57:27 +00:00
Vedant Kumar
ae0e243fb0 [llvm-cov] Document some fields in a class (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282203 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-22 21:49:47 +00:00
Vedant Kumar
ef76be0d1e [llvm-cov] Add the ability to specify directories of input source files
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282202 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-22 21:49:43 +00:00
Vedant Kumar
139080743f [llvm-cov] Demangle names for hidden instantiation views
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282020 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-20 21:27:48 +00:00
Vedant Kumar
764028eefa [llvm-cov] Emit a link to some documentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281883 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 02:15:59 +00:00
Vedant Kumar
1b70b5dcc9 [llvm-cov] Delete the NonCodeLines field, it was always dead
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281882 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 01:46:01 +00:00
Vedant Kumar
70b43c34b6 [llvm-cov] Teach the coverage exporter about instantiation coverage
While we're at it, re-use the logic from CoverageReport to compute
summaries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281877 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 00:38:29 +00:00
Vedant Kumar
a830753405 [llvm-cov] Make a helper method static for re-use (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281876 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 00:38:25 +00:00
Vedant Kumar
e17f26f066 [llvm-cov] Track function and instantiation coverage separately
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281875 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 00:38:23 +00:00
Vedant Kumar
40817d86f0 [llvm-cov] Don't recompute the 'Covered' field from *CoverageInfo (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281874 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 00:38:18 +00:00
Vedant Kumar
6360ab9da4 [llvm-cov] Make 'adjustColumnWidths' do less work
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).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281873 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 00:38:16 +00:00
Vedant Kumar
c063c43a4e [llvm-cov] Drop another redundant 'No.' suffix
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281872 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19 00:38:14 +00:00
Vedant Kumar
4cb35092d0 [llvm-cov] Move some layout logic to the right spot (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281590 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15 06:49:13 +00:00
Vedant Kumar
61f5694c30 [llvm-cov] Hide instantiation views for unexecuted functions
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281589 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15 06:44:51 +00:00
Vedant Kumar
2fcbfcf470 [llvm-cov] Don't create 'jump to ...' links in nested views
Doing so is pointless, since the whole view is usually visible in a
small amount of space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281588 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15 06:44:48 +00:00
Vedant Kumar
7551d48f2f [llvm-cov] Make a method name more accurate (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281581 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15 04:45:59 +00:00
Vedant Kumar
90562cd08a [llvm-cov] Don't print a verbose title when looking at one file
Having the same title, timestamp, etc. occur repeatedly creates an
unnecessary distraction when paging through a report.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281579 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-15 04:41:39 +00:00
Vedant Kumar
e7f7e18127 [llvm-cov] Just emit the version number in the index file
Having the version information in every view is distracting, especially
if there are several sub-views.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281414 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-13 23:00:13 +00:00
Ying Yi
503f4620ba [llvm-cov] - Included footer "Generated by llvm-cov -- llvm version <version number>" in the coverage report.
The llvm-cov version information will be useful to the user when comparing the code coverage across different versions of llvm-cov. This patch provides the llvm-cov version information in the generated coverage report.

Differential Revision: https://reviews.llvm.org/D24457

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281321 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-13 11:28:31 +00:00
Vedant Kumar
a8edd76b0e [llvm-cov] Move the 'jump to first unexecuted line' link
Having it in the same row as the source name is jarring. Move it next to
the "Source" column label.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281146 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-10 19:37:26 +00:00
Vedant Kumar
ce19c1cc95 [llvm-cov] Minor visual tweaks for html reports
- Change the location of the 'Region Coverage' column.
  - Use less css and text for some labels.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281145 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-10 19:37:20 +00:00
Vedant Kumar
07e4072b5d [llvm-cov] Remove some asserts in the html renderer (NFC)
These asserts are making tests fragile. The renderer does not enter an
invalid state when they fail, however, it may spit out a garbled
coverage report because the source text no longer matches the provided
coverage mapping.

Another follow-up to r281072.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281076 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-09 18:44:40 +00:00
Vedant Kumar
3beac7c40e [llvm-cov] Handle native paths correctly in the text index
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!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281062 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-09 17:37:11 +00:00
Vedant Kumar
84dc7510c9 [llvm-cov] Emit a summary in the report directory's index
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281011 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-09 01:32:55 +00:00
Vedant Kumar
85e096da4e [llvm-cov] Constify some methods (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281010 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-09 01:32:51 +00:00
Vedant Kumar
006e320c47 [llvm-cov] Add an API to prepare file reports (NFC)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281009 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-09 01:32:49 +00:00
Vedant Kumar
111f4fbf9a [llvm-cov] Fix issues with segment highlighting in the html view
The text and html coverage views take different approaches to emitting
highlighted regions. That's because this problem is easier in the text
view: there's no need to worry about escaping text or adding tooltip
content to a highlighted snippet.

Unfortunately, the html view didn't get region highlighting quite right.

This patch fixes the situation, bringing parity between the two views.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280981 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-08 19:18:23 +00:00
Vedant Kumar
d2e36ca513 [llvm-cov] Use less space to describe source names
In r279628, we made SourceCoverageView list the binary associated with a
view and started adding labels (e.g "Source: foo" or "Function: bar") to
everything. Condense this information a bit to unclutter reports.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280896 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-08 00:56:48 +00:00
Vedant Kumar
a57be10507 [llvm-cov] Drop the longest common filename prefix from summaries
Remove the longest common prefix from filenames when printing coverage
summaries. This makes them easier to compare.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280895 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-08 00:56:43 +00:00
Vedant Kumar
423e0ff90b [llvm-cov] Use colors consistently in the summary
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280765 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 22:46:00 +00:00
Vedant Kumar
ff7a0df044 [llvm-cov] Clean up the summary class, delete dead code (NFC)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280764 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 22:45:57 +00:00
Ying Yi
84f34c0155 [llvm-cov] Add the project summary to the text coverage report for each source file.
This patch is a spin-off from https://reviews.llvm.org/D23922. It extends the text view to preserve the same feature as the html view.

Differential Revision: https://reviews.llvm.org/D24241


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 21:41:38 +00:00
Ying Yi
f73cd14f4a [llvm-cov] Add the "Go to first unexecuted line" feature.
This patch provides easy navigation to find the zero count lines, especially useful when the source file is very large.

Differential Revision: https://reviews.llvm.org/D23277


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280739 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-06 19:31:18 +00:00
Vedant Kumar
751f50e8f5 [llvm-cov] Drop redundant "No." suffix in a column title
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280181 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-31 00:09:44 +00:00