aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/CodeCoverage.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-06-13Reland "[llvm-cov] Add support for baseline coverage" (#144130)Fabian Meumertzheim1-28/+50
When no profile is provided, but the new --empty-profile option is specified, the export/report/show commands now emit coverage data equivalent to that obtained from a profile with all zero counters ("baseline coverage"). This is useful for build systems (e.g. Bazel) that can track coverage information for each build target, even those that are never linked into tests and thus don't have runtime coverage data recorded. By merging in baseline coverage, lines in files that aren't linked into tests are correctly reported as uncovered. Reland with fixes to `CoverageMappingTest.cpp`. Reverts llvm/llvm-project#144121
2025-06-13Revert "[llvm-cov] Add support for baseline coverage" (#144121)Keith Smiley1-50/+28
Reverts llvm/llvm-project#117910 ``` /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp /home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/unittests/ProfileData/CoverageMappingTest.cpp:281:28: error: 'std::reference_wrapper' may not intend to support class template argument deduction [-Werror,-Wctad-maybe-unsupported] 281 | std::make_optional(std::reference_wrapper(*ProfileReader)); | ^ /usr/lib/gcc/ppc64le-redhat-linux/8/../../../../include/c++/8/bits/refwrap.h:289:11: note: add a deduction guide to suppress this warning 289 | class reference_wrapper | ^ ```
2025-06-13[llvm-cov] Add support for baseline coverage (#117910)Fabian Meumertzheim1-28/+50
When no profile is provided, but the new --empty-profile option is specifed, the export/report/show commands now emit coverage data equivalent to that obtained from a profile with all zero counters ("baseline coverage"). This is useful for build systems (e.g. Bazel) that can track coverage information for each build target, even those that are never linked into tests and thus don't have runtime coverage data recorded. By merging in baseline coverage, lines in files that aren't linked into tests are correctly reported as uncovered.
2025-04-24[llvm-cov] Fix branch counts of template functions (second attempt) (#135074)stma2471-0/+5
This PR is a second attempt for issue #111743 to finish reverted PR #113925. Added option "--unify-instantiations" to llvm-cov export to combine branch execution counts of C++ template instantiations. Fix non-deterministic behavior.
2025-04-17[llvm] Use llvm::binary_search (NFC) (#136228)Kazu Hirata1-1/+1
2025-03-29[bugpoint] Avoid repeated hash lookups (NFC) (#133616)Kazu Hirata1-2/+1
2024-12-27llvm-cov: Introduce `--binary-counters` (#120841)NAKAMURA Takumi1-0/+7
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-20llvm-cov: Introduce `-show-created-time` to suppress timestamps (#120417)NAKAMURA Takumi1-6/+13
This shouldn't affect anything since `-show-created-time=true` by default. Timestamps sometimes prevent reproducible build.
2024-12-02Revert "[llvm-cov] Fix branch counts of template functions (#111743)" (#118398)Alan Phipps1-5/+0
Reverts llvm/llvm-project#113925 Reverting to address buildbot failures.
2024-12-02[llvm-cov] Fix branch counts of template functions (#111743) (#113925)stma2471-0/+5
Added option "--unify-instantiations" to llvm-cov export to combine branch execution counts of C++ template instantiations. on-behalf-of: @e-solutions-GmbH <info@esolutions.de>
2024-07-05[llvm-cov] Remove View member from MCDCView and BranchView (#97734)Nikita Popov1-35/+15
These were never actually used, and the way they were constructed doesn't really make sense. Fixes https://github.com/llvm/llvm-project/issues/93798.
2024-06-13[llvm-project] Fix typo "seperate" (#95373)Jay Foad1-1/+1
2024-03-05Rename llvm::ThreadPool -> llvm::DefaultThreadPool (NFC) (#83702)Mehdi Amini1-1/+1
The base class llvm::ThreadPoolInterface will be renamed llvm::ThreadPool in a subsequent commit. This is a breaking change: clients who use to create a ThreadPool must now create a DefaultThreadPool instead.
2024-01-27[llvm-cov] Simplify branch/MCDC subviews. NFCFangrui Song1-17/+9
Remove unneeded empty check and reundant copies. NFC
2023-12-13Reland "[Coverage][llvm-cov] Enable MC/DC Support in LLVM Source-based Code ↵Alan Phipps1-0/+56
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-55/+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/+55
(2/3) Part 2 of 3. This includes the Visualization and Evaluation components. Differential Revision: https://reviews.llvm.org/D138847
2023-09-06[llvm-cov] - Output better error message when the error kind is ↵MaggieYingYi1-17/+17
`coveragemap_error::malforme`. (#65264) The current llvm-cov error message for kind `coveragemap_error::malforme`, just gives the issue kind without any reason for what caused the issue. This patch is aimed at improving the llvm-cov error message to help identify what caused the issue. Reviewed By: MaskRay Close: https://github.com/llvm/llvm-project/pull/65264
2023-08-24[llvm-cov] Support directory layout in coverage reportsYuhao Gu1-0/+5
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-23[llvm-cov] Allow multiple remaps in --path-equivalenceTomas Camin1-25/+36
Previously the --path-equivalence parameter would allow to specify a single remap pair (coverage data path - local source file path). This patch changes this allowing to pass as many remaps as needed. Reviewed By: keith Differential Revision: https://reviews.llvm.org/D154223
2023-03-03[llvm-cov] Optionally fail on missing binary IDDaniel Thornburgh1-3/+10
This adds the --check-binary-id flag that makes sure that an object file is available for every binary ID mentioned in the given profile. This should help make the tool more robust in CI environments where it's expected that coverage mappings should be available for every object contributing to the profile. Reviewed By: gulfem Differential Revision: https://reviews.llvm.org/D144308
2023-02-17[llvm-cov] Create syntax to pass source w/o binary.Daniel Thornburgh1-1/+1
Since binary ID lookup makes CLI object arguments optional, it should be possible to pass a list of source files without a binary. Unfortunately, the current syntax will always interpret the first source file as a binary. This change adds a `-sources` option to cause all later positional arguments to be considered sources. Reviewed By: gulfem Differential Revision: https://reviews.llvm.org/D144207
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott1-1/+1
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2023-02-01[NFC][Profile] Access profile through VirtualFileSystemSteven Wu1-1/+2
Make the access to profile data going through virtual file system so the inputs can be remapped. In the context of the caching, it can make sure we capture the inputs and provided an immutable input as profile data. Reviewed By: akyrtzi, benlangmuir Differential Revision: https://reviews.llvm.org/D139052
2023-01-26Reland: [llvm-cov] Look up object files using debuginfodDaniel Thornburgh1-6/+24
Reviewed By: gulfem Differential Revision: https://reviews.llvm.org/D136702
2023-01-25Revert "[llvm-cov] Look up object files using debuginfod"Douglas Yung1-24/+6
This reverts commit efbc8bb18eda63007216ad0cb5a8de04963eddd5. This change is causing failures when detecting curl on several build bots: - https://lab.llvm.org/buildbot/#/builders/247/builds/884 - https://lab.llvm.org/buildbot/#/builders/231/builds/7688 - https://lab.llvm.org/buildbot/#/builders/121/builds/27389 - https://lab.llvm.org/buildbot/#/builders/230/builds/8464 - https://lab.llvm.org/buildbot/#/builders/57/builds/24209 - https://lab.llvm.org/buildbot/#/builders/127/builds/42722
2023-01-25[llvm-cov] Look up object files using debuginfodDaniel Thornburgh1-6/+24
Reviewed By: gulfem Differential Revision: https://reviews.llvm.org/D136702
2022-12-18Remove redundant .c_str() and .get() callsGregory Alfonso1-6/+6
Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D139485
2022-12-14[tools] llvm::Optional => std::optionalFangrui Song1-3/+3
2022-12-08[llvm] Call reserve before push_back in a loopGregory Alfonso1-0/+1
It is generally good practice, if you know how big the vector is going to be in the end, to reserve before continually calling "push_back" or "emplace_back" Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D139483
2022-12-02[tools] Use std::nullopt instead of None (NFC)Kazu Hirata1-3/+4
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-12-01Support: Convert Program APIs to std::optionalMatt Arsenault1-1/+2
2022-11-26[llvm-cov] Use std::optional in CodeCoverage.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-10-14[llvm-cov] Allow branch coverage to be skipped when exporting for LCOVAlan Phipps1-0/+5
This small patch adds a '--skip-branches' option to the llvm-cov export options. This option allows branch coverage information to be skipped from the exported LCOV directives if it's not needed. For now, this only works when exporting LCOV (which is noted in the option description), but it can be extended for JSON later if it makes sense. Differential Revision: https://reviews.llvm.org/D135986
2022-08-01[llvm-cov] Remove deprecated -name-whitelist after D112816Fangrui Song1-24/+6
2022-07-21[llvm-cov] Improve error message by printing the object file name that ↵Zequan Wu1-2/+1
produces error If error occurs on constructing coverage info for one of the object files, it prints the name of the object file, so that users know which one is the cause of error. Differential Revision: https://reviews.llvm.org/D130196
2022-07-15[llvm-cov] Add error message for missing profdata on report and export ↵Zequan Wu1-1/+13
subcommands. When profdata is missing on report and export commands, the error message is indistinguishable from missing instrumented binary file. This adds the error message for report and export commands. Differential Revision: https://reviews.llvm.org/D129791
2022-06-20Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+1
2022-06-08[llvm-cov] Assume repeat architectures for universal binariesKeith Smiley1-0/+3
In the case you pass multiple universal binaries to llvm-cov, assume that if only 1 architecture is passed, it should be used for all the passed binaries. This makes it easier to use multiple multi-arch binaries, since it's likely very rare that your architectures mismatch significantly if you also have multiple binaries in a single llvm-cov invocation. If the architecture is invalid for any of the passed binaries, it will still fail later. Differential Revision: https://reviews.llvm.org/D121667
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song1-2/+2
2022-06-05Remove unneeded cl::ZeroOrMore for cl::opt/cl::list optionsFangrui Song1-3/+3
2022-06-04Remove unneeded cl::ZeroOrMore for cl::list optionsFangrui Song1-2/+2
2022-06-04Remove unneeded cl::ZeroOrMore for cl::opt optionsFangrui Song1-1/+1
Similar to 557efc9a8b68628c2c944678c6471dac30ed9e8e. This commit handles options where cl::ZeroOrMore is more than one line below cl::opt.
2022-03-04[llvm-cov] New parameters to set coverage coverage_watermarkPetr Hosek1-0/+46
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-11-26[LLVM][llvm-cov] Inclusive language: rename option -name-whitelist to ↵Zarko Todorovski1-12/+30
-name-allowlist Renamed the option for llvm-cov and changed variable names to use more inclusive terms. Also changed the binary for the test. Reviewed By: alanphipps Differential Revision: https://reviews.llvm.org/D112816
2021-09-10[llvm-cov] Add error for invalid -path-equivalence formatKeith Smiley1-2/+10
Differential Revision: https://reviews.llvm.org/D109042
2021-05-11[Coverage] Support overriding compilation directoryPetr Hosek1-1/+7
When making compilation relocatable, for example in distributed compilation scenarios, we want to set compilation dir to a relative value like `.` but this presents a problem when generating reports because if the file path is relative as well, for example `..`, you may end up writing files outside of the output directory. This change introduces a flag that allows overriding the compilation directory that's stored inside the profile with a different value that is absolute. Differential Revision: https://reviews.llvm.org/D100232
2021-03-24[llvm-cov] Check path emptyness in path-equivalence after removing dots.Zequan Wu1-1/+1