aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/SourceCoverageViewText.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-08[llvm] Compare std::optional<T> to values directly (NFC) (#143340)Kazu Hirata1-2/+2
This patch transforms: X && *X == Y to: X == Y where X is of std::optional<T>, and Y is of T or similar.
2024-12-27llvm-cov: Introduce `--binary-counters` (#120841)NAKAMURA Takumi1-3/+3
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-37/+28
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-10-20[Coverage] Introduce "partial fold" on BranchRegion (#112694)NAKAMURA Takumi1-20/+27
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-09-24[llvm] Use std::optional::value_or (NFC) (#109890)Kazu Hirata1-2/+2
2024-06-17[llvm-cov] Coverage report HTML UI to jump between uncovered parts of code ↵Hana Dusíková1-2/+1
(#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-02-16[llvm-cov][CoverageView] minor fix/improvement to HTML and text coverage ↵Wentao Zhang1-1/+2
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-13Reland "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code ↵Alan Phipps1-0/+51
Coverage (2/3)" Part 2 of 3. This includes the Visualization and Evaluation components. Differential Revision: https://reviews.llvm.org/D138847
2023-09-20Revert "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code ↵Alan Phipps1-51/+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/+51
(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-0/+65
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 SourceCoverageViewText.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
2021-01-05[Coverage] Add support for Branch Coverage in LLVM Source-Based Code CoverageAlan Phipps1-1/+49
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
2019-08-02Revert r367649: Improve raw_ostream so that you can "write" colors using ↵Rui Ueyama1-1/+1
operator<< This reverts commit r367649 in an attempt to unbreak Windows bots. llvm-svn: 367658
2019-08-02Improve raw_ostream so that you can "write" colors using operator<<Rui Ueyama1-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
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-05-01Remove \brief commands from doxygen comments.Adrian Prantl1-2/+2
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
2017-11-09[Coverage] Use the wrapped segment when a line has entry segmentsVedant Kumar1-5/+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-2/+1
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-10/+16
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-1/+2
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-1/+1
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-1/+2
Differential Revision: https://reviews.llvm.org/D38457 llvm-svn: 314782
2017-09-28[llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson1-4/+4
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-4/+4
options" Test failures. llvm-svn: 314314
2017-09-27[llvm-cov] Create directory structure when filtering using -name*= optionsSean Eveson1-4/+4
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
2017-09-08[llvm-cov] Unify region marker placement between text/html modesVedant Kumar1-5/+8
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
2016-10-25[llvm-cov] Do not print out the filename of the object fileVedant Kumar1-2/+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
2016-09-23[llvm-cov] Get rid of all invalid filename referencesVedant Kumar1-2/+2
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
2016-09-15[llvm-cov] Hide instantiation views for unexecuted functionsVedant Kumar1-1/+6
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
2016-09-15[llvm-cov] Make a method name more accurate (NFC)Vedant Kumar1-3/+2
llvm-svn: 281581
2016-09-13[llvm-cov] Just emit the version number in the index fileVedant Kumar1-4/+1
Having the version information in every view is distracting, especially if there are several sub-views. llvm-svn: 281414
2016-09-13[llvm-cov] - Included footer "Generated by llvm-cov -- llvm version <version ↵Ying Yi1-1/+7
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 llvm-svn: 281321
2016-09-10[llvm-cov] Move the 'jump to first unexecuted line' linkVedant Kumar1-3/+3
Having it in the same row as the source name is jarring. Move it next to the "Source" column label. llvm-svn: 281146
2016-09-09[llvm-cov] Emit a summary in the report directory's indexVedant Kumar1-3/+6
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
2016-09-08[llvm-cov] Use less space to describe source namesVedant Kumar1-6/+2
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. llvm-svn: 280896
2016-09-06[llvm-cov] Add the project summary to the text coverage report for each ↵Ying Yi1-2/+2
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 llvm-svn: 280756
2016-09-06[llvm-cov] Add the "Go to first unexecuted line" feature.Ying Yi1-1/+2
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 llvm-svn: 280739
2016-08-24[llvm-cov] Add the project summary to each source file coverage report.Ying Yi1-1/+20
This patch includes the following changes: - Included header "Code coverage report" and include the date that the report was created. - Included title (as specified in a command line option, (i.e llvm-cov -project-title="Simple Test") - In the summary, list the elf files that the source code file has contributed to. - Used column heading for "Line No.", "Count No.", Source". Differential Revision: https://reviews.llvm.org/D23345 llvm-svn: 279628
2016-07-06Minor formatting change, NFCVedant Kumar1-7/+3
The rest of llvm-cov does not use LLVM_ATTRIBUTE_UNUSED. Leave unused params unnamed to be consistent. llvm-svn: 274694
2016-06-29Use LLVM_ATTRIBUTE_UNUSED instead of void casts; NFCVedant Kumar1-7/+7
llvm-svn: 274139
2016-06-29[llvm-cov] Minor cleanups to prepare for the html format patchVedant Kumar1-2/+11
- Add renderView{Header,Footer}, renderLineSuffix, and hasSubViews to support creating tables with nested views. - Move the 'Format' cl::opt to make it easier to extend. - Just create one function view file, instead of overwriting the same file for every new function. Add a regression test for this. llvm-svn: 274086
2016-06-28[llvm-cov] Create an index of reports in -output-dir modeVedant Kumar1-9/+22
This index lists the reports available in the 'coverage' sub-directory. This will help navigate coverage output from large projects. This commit factors the file creation code out of SourceCoverageView and into CoveragePrinter. llvm-svn: 274029
2016-06-28Reapply "[llvm-cov] Add an -output-dir option for the show sub-command""Vedant Kumar1-0/+9
Passing -output-dir path/to/dir to llvm-cov show creates path/to/dir if it doesn't already exist, and prints reports into that directory. In function view mode, all views are written into path/to/dir/functions.$EXTENSION. In file view mode, all views are written into path/to/dir/coverage/$PATH.$EXTENSION. Changes since the initial commit: - Avoid accidentally closing stdout twice. llvm-svn: 273985
2016-06-28Revert "[llvm-cov] Add an -output-dir option for the show sub-command"Vedant Kumar1-9/+0
This reverts commit r273971. test/profile/instrprof-visibility.cpp is failing because of an uncaught error in SafelyCloseFileDescriptor. llvm-svn: 273978