aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-12-27llvm-cov: Introduce `--binary-counters` (#120841)NAKAMURA Takumi1-6/+9
In `llvm-cov show`, this option rounds counters (line, branch) to `[1,0]` at rendering. This will be useful when the number of counts doesn't interest but **Covered/uncoverd** does.
2024-12-18llvm-cov: Refactor SourceCoverageView::renderBranchView().NAKAMURA Takumi1-45/+25
NFC except for calculating `Total`. I've replaced `(uint64_t)+(uint64_t)` with `(double)+(double)`. This is still inexact with large numbers `(1LL << 53)` but will be expected to prevent possible overflow.
2024-12-18SourceCoverageViewHTML.cpp: Reformat JSNAKAMURA Takumi1-30/+25
2024-11-12[llvm] Remove redundant control flow statements (NFC) (#115831)Kazu Hirata1-1/+0
Identified with readability-redundant-control-flow.
2024-10-20[Coverage] Introduce "partial fold" on BranchRegion (#112694)NAKAMURA Takumi1-21/+30
Currently both True/False counts were folded. It lost the information, "It is True or False before folding." It prevented recalling branch counts in merging template instantiations. In `llvm-cov`, a folded branch is shown as: - `[True: n, Folded]` - `[Folded, False n]` In the case If `n` is zero, a branch is reported as "uncovered". This is distinguished from "folded" branch. When folded branches are merged, `Folded` may be dissolved. In the coverage map, either `Counter` is `Zero`. Currently both were `Zero`. Since "partial fold" has been introduced, either case in `switch` is omitted as `Folded`. Each `case:` in `switch` is reported as `[True: n, Folded]`, since `False` count doesn't show meaningful value. When `switch` doesn't have `default:`, `switch (Cond)` is reported as `[Folded, False: n]`, since `True` count was just the sum of `case`(s). `switch` with `default` can be considered as "the statement that doesn't have any `False`(s)".
2024-06-17[llvm-cov] Coverage report HTML UI to jump between uncovered parts of code ↵Hana Dusíková1-23/+197
(#95662) I replaced "jump to first uncovered line" with UI buttons and keyboard shortcut to jump between uncovered parts of code: lines (key L), branchs (key B), regions (key R). User can also jump in reverse direction with shift+key.
2024-06-05[llvm-cov] Add HTML dark theme support (#93080)EdJoPaTo1-35/+41
Personally I use [cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) which creates helpful HTML coverage reports, but they don't support a dynamic dark themes. I updated the styling to support both dark and bright color themes based on the browser preference. The bright theme should look similar to the current theme. I also improved some color contrasts (Firefox accessibility tool reported them) and ensured that line-number links keep their text-decoration. Things that both have `.tooltip` and `.red` look kinda odd as the coloring is now based on tinting with transparency. Given that the tooltip should always show 0 in such cases (otherwise it wouldn't be red) the tooltip could be removed there on the HTML generation, but that seemed out of scope for my style only change.
2024-02-16[llvm-cov][CoverageView] minor fix/improvement to HTML and text coverage ↵Wentao Zhang1-4/+5
output (#80952) 1. add the missing condition for MC/DC in hasSubViews() 2. add style for selected line 3. remove name="Ln" attribute in the link within MC/DC views 4. remove color for \n
2023-12-19[llvm-cov] format cells in report with 0/0 branches/functions/lines ↵Hana Dusíková1-4/+20
differenly (gray instead red) and make the table a bit nicer (#75780)
2023-12-13Reland "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code ↵Alan Phipps1-0/+52
Coverage (2/3)" Part 2 of 3. This includes the Visualization and Evaluation components. Differential Revision: https://reviews.llvm.org/D138847
2023-12-09[ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (#74916)Kazu Hirata1-1/+1
This patch renames {starts,ends}with to {starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. Since there are only a handful of occurrences, this patch skips the deprecation phase and simply renames them.
2023-09-20Revert "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code ↵Alan Phipps1-52/+0
Coverage (2/3)" This reverts commit 618a22144db5e45da8c95dc22064103e1b5e5b71. Buildbots failing on windows and one other issue.
2023-09-20[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code Coverage ↵Alan Phipps1-0/+52
(2/3) Part 2 of 3. This includes the Visualization and Evaluation components. Differential Revision: https://reviews.llvm.org/D138847
2023-08-24[llvm-cov] Support directory layout in coverage reportsYuhao Gu1-80/+311
This is a GSoC 2023 project ([discourse link](https://discourse.llvm.org/t/coverage-support-a-hierarchical-directory-structure-in-generated-coverage-html-reports/68239)). llvm-cov currently generates a single top-level index HTML file, which causes rendering scalability issues in large projects. This patch adds support for hierarchical directory structure into the HTML reports to solve scalability issues by introducing the following changes: - Added a new command line option `--show-directory-coverage` for `llvm-cov show`. It works both for `--format=html` and `--format=text`. - Two new classes: `CoveragePrinterHTMLDirectory` and `CoveragePrinterTextDirectory` was added to support the new option. - A tool class `DirectoryCoverageReport` was added to support the two classes above. - Updated the document. - Added a new regression test for `--show-directory-coverage`. Reviewed By: phosek, gulfem Differential Revision: https://reviews.llvm.org/D151283
2023-08-18[llvm-cov] Use uint64_t to avoid overflow in additionFlightor1-1/+3
Reviewed By: alanphipps Differential Revision: https://reviews.llvm.org/D157608
2022-12-06[llvm] Don't include Optional.h (NFC)Kazu Hirata1-1/+0
These source files no longer use Optional<T>, so they do not need to include Optional.h. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02[tools] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+1
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-26[llvm-cov] Use std::optional in SourceCoverageViewHTML.cpp (NFC)Kazu Hirata1-1/+2
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-06-25[llvm] Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-2/+2
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
2022-06-20[llvm] Don't use Optional::getValue (NFC)Kazu Hirata1-1/+1
2022-03-04[llvm-cov] New parameters to set coverage coverage_watermarkPetr Hosek1-18/+18
Add a pairs of parameters to set coverage watermark for llvm-cov, and user can change the percentage thresholds marked with different colors in the report. Patch By: tanjinhua Differential Revision: https://reviews.llvm.org/D116876
2022-01-08[llvm] Fix bugprone argument comments (NFC)Kazu Hirata1-1/+1
Identified with bugprone-argument-comment.
2021-01-12[llvm] Remove redundant string initialization (NFC)Kazu Hirata1-2/+2
Identified with readability-redundant-string-init.
2021-01-05[Coverage] Add support for Branch Coverage in LLVM Source-Based Code CoverageAlan Phipps1-0/+72
This is an enhancement to LLVM Source-Based Code Coverage in clang to track how many times individual branch-generating conditions are taken (evaluate to TRUE) and not taken (evaluate to FALSE). Individual conditions may comprise larger boolean expressions using boolean logical operators. This functionality is very similar to what is supported by GCOV except that it is very closely anchored to the ASTs. Differential Revision: https://reviews.llvm.org/D84467
2020-04-11Simplify string joins. NFCI.Benjamin Kramer1-2/+1
2020-02-10Revert "Remove redundant "std::move"s in return statements"Bill Wendling1-1/+1
The build failed with error: call to deleted constructor of 'llvm::Error' errors. This reverts commit 1c2241a7936bf85aa68aef94bd40c3ba77d8ddf2.
2020-02-10Remove redundant "std::move"s in return statementsBill Wendling1-1/+1
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-4/+4
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-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
2018-12-20[binutils] NFC: fix clang-tidy warning: use empty() instead of size() == 0Jordan Rupprecht1-1/+1
llvm-svn: 349710
2018-05-31[ADT] Make escaping fn conform to coding guidelinesJonas Devlieghere1-1/+1
As noted by Adrian on llvm-commits, PrintHTMLEscaped and PrintEscaped in StringExtras did not conform to the LLVM coding guidelines. This commit rectifies that. llvm-svn: 333669
2018-05-30[llvm-cov] Use the new PrintHTMLEscaped utilityVedant Kumar1-20/+18
This removes some duplicate logic to escape characters in HTML output. llvm-svn: 333608
2018-05-22[Coverage] Update CSS to make HTML reports copy-paste friendly.Max Moroz1-0/+3
Summary: This minor change allows to copy snippets from HTML reports so they will be pasted in the following format: %LineNumber%\t%HitCount%\t%CodeLine% rather then being split onto multiple lines. To see this in action, try copy pasting from https://chromium-coverage.appspot.com/reports/560344/linux/chromium/src/third_party/zlib/compress.c.html Requested in https://bugs.chromium.org/p/chromium/issues/detail?id=845571 Reviewers: vsk Reviewed By: vsk Subscribers: llvm-commits, morehouse, kcc Differential Revision: https://reviews.llvm.org/D47231 llvm-svn: 333034
2018-01-31[llvm-cov] Fix incorrect usage of .precision specifier in format() call.Max Moroz1-1/+1
Summary: Existing version doesn't work on Windows as it always prints 0.00. Reviewers: Dor1s Reviewed By: Dor1s Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D42767 llvm-svn: 323923
2018-01-31[llvm-cov] Improvements for summary report generated in HTML format.Max Moroz1-14/+37
Summary: This commit adds the following changes: 1) coverage numbers are aligned to the left and padded with spaces in order to provide better readability for percentage values, e.g.: ``` file1 | 89.13% (123 / 2323) | 100.00% (55 / 55) | 9.33% (14545 / 234234) file_asda | 1.78% ( 23 / 4323) | 32.31% (555 / 6555) | 67.89% (1545 / 2234) fileXXX | 100.00% (12323 / 12323) | 100.00% (555 / 555) | 100.00% (12345 / 12345) ``` 2) added "hover" attribute to CSS for highlighting table row under mouse cursor see screenshot attached to the phabricator review page {F5764813} 3) table title row and "totals" row now use bold text Reviewers: vsk, morehouse Reviewed By: vsk Subscribers: kcc, llvm-commits Differential Revision: https://reviews.llvm.org/D42093 llvm-svn: 323892
2017-12-13Remove redundant includes from tools.Michael Zolotukhin1-1/+0
llvm-svn: 320631
2017-11-09[llvm-cov] Don't render empty region marker linesVedant Kumar1-1/+1
This fixes an issue where llvm-cov prints an empty line, thinking it needs to display region markers, when it actually doesn't. llvm-svn: 317762
2017-11-09[Coverage] Use the wrapped segment when a line has entry segmentsVedant Kumar1-6/+6
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. llvm-svn: 317761
2017-10-18[llvm-cov] Use the coverage namespace. NFC.Vedant Kumar1-3/+2
This is a simple code cleanup. It will facilitate moving LineCoverageIterator to libCoverage. llvm-svn: 316140
2017-10-18[llvm-cov] Suppress sub-line highlights in simple casesVedant Kumar1-0/+2
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. llvm-svn: 316109
2017-10-18[llvm-cov] Pass LineCoverageStats in SourceCoverageView. NFC.Vedant Kumar1-9/+11
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. llvm-svn: 316108
2017-10-18[llvm-cov] Highlight gaps in consecutive uncovered regionsVedant Kumar1-2/+3
llvm-cov typically doesn't highlight gap segments, but it should if the gap occurs after an uncovered region in order to preserve continuity. llvm-svn: 316107
2017-10-14[llvm-cov] Factor out logic to iterate over line coverage stats (NFC)Vedant Kumar1-2/+2
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. llvm-svn: 315789
2017-10-03[llvm-cov] Hide files with no coverage from the index when filtering by nameSean Eveson1-2/+3
Differential Revision: https://reviews.llvm.org/D38457 llvm-svn: 314782
2017-09-28[llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson1-5/+5
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
2017-09-27Revert "[llvm-cov] Create directory structure when filtering using -name*= ↵Sean Eveson1-5/+5
options" Test failures. llvm-svn: 314314
2017-09-27[llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson1-5/+5
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
2017-09-18[Coverage] Use gap regions to select better line exec countsVedant Kumar1-1/+1
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. llvm-svn: 313597