aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-cov/CodeCoverage.cpp
diff options
context:
space:
mode:
authorDaniel Thornburgh <dthorn@google.com>2023-02-17 13:43:57 -0800
committerDaniel Thornburgh <dthorn@google.com>2023-03-03 10:24:21 -0800
commit072e07a9d5928fd3b1c1dabeac82890713ce172b (patch)
tree3940c80f7e2b9c98029d81a4a0a1a9b241644d45 /llvm/tools/llvm-cov/CodeCoverage.cpp
parent3ac8d322100bc72aaacb67f13eb21d9b644f9930 (diff)
downloadllvm-072e07a9d5928fd3b1c1dabeac82890713ce172b.zip
llvm-072e07a9d5928fd3b1c1dabeac82890713ce172b.tar.gz
llvm-072e07a9d5928fd3b1c1dabeac82890713ce172b.tar.bz2
[llvm-cov] Optionally fail on missing binary ID
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
Diffstat (limited to 'llvm/tools/llvm-cov/CodeCoverage.cpp')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index a7518a3..02448dc 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -185,6 +185,8 @@ private:
std::unique_ptr<SpecialCaseList> NameAllowlist;
std::unique_ptr<object::BuildIDFetcher> BIDFetcher;
+
+ bool CheckBinaryIDs;
};
}
@@ -440,9 +442,9 @@ std::unique_ptr<CoverageMapping> CodeCoverageTool::load() {
warning("profile data may be out of date - object is newer",
ObjectFilename);
auto FS = vfs::getRealFileSystem();
- auto CoverageOrErr =
- CoverageMapping::load(ObjectFilenames, PGOFilename, *FS, CoverageArches,
- ViewOpts.CompilationDirectory, BIDFetcher.get());
+ auto CoverageOrErr = CoverageMapping::load(
+ ObjectFilenames, PGOFilename, *FS, CoverageArches,
+ ViewOpts.CompilationDirectory, BIDFetcher.get(), CheckBinaryIDs);
if (Error E = CoverageOrErr.takeError()) {
error("Failed to load coverage: " + toString(std::move(E)));
return nullptr;
@@ -761,6 +763,10 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
"compilation-dir", cl::init(""),
cl::desc("Directory used as a base for relative coverage mapping paths"));
+ cl::opt<bool> CheckBinaryIDs(
+ "check-binary-ids", cl::desc("Fail if an object couldn't be found for a "
+ "binary ID in the profile"));
+
auto commandLineParser = [&, this](int argc, const char **argv) -> int {
cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n");
ViewOpts.Debug = DebugDump;
@@ -770,6 +776,7 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
} else {
BIDFetcher = std::make_unique<object::BuildIDFetcher>(DebugFileDirectory);
}
+ this->CheckBinaryIDs = CheckBinaryIDs;
if (!CovFilename.empty())
ObjectFilenames.emplace_back(CovFilename);