summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/llvm-cov/CodeCoverage.cpp23
-rw-r--r--llvm/tools/llvm-cov/CoverageFilters.cpp5
-rw-r--r--llvm/tools/llvm-cov/CoverageFilters.h13
3 files changed, 40 insertions, 1 deletions
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index e5878df6c15..f75fcb8884c 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -150,6 +150,9 @@ private:
std::mutex LoadedSourceFilesLock;
std::vector<std::pair<std::string, std::unique_ptr<MemoryBuffer>>>
LoadedSourceFiles;
+
+ /// Whitelist from -name-whitelist to be used for filtering.
+ std::unique_ptr<SpecialCaseList> NameWhitelist;
};
}
@@ -561,6 +564,12 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
cl::desc("Show code coverage only for functions with the given name"),
cl::ZeroOrMore, cl::cat(FilteringCategory));
+ cl::list<std::string> NameFilterFiles(
+ "name-whitelist", cl::Optional,
+ cl::desc("Show code coverage only for functions listed in the given "
+ "file"),
+ cl::ZeroOrMore, cl::cat(FilteringCategory));
+
cl::list<std::string> NameRegexFilters(
"name-regex", cl::Optional,
cl::desc("Show code coverage only for functions that match the given "
@@ -643,11 +652,23 @@ int CodeCoverageTool::run(Command Cmd, int argc, const char **argv) {
ViewOpts.DemanglerOpts.swap(DemanglerOpts);
}
+ // Read in -name-whitelist files.
+ if (!NameFilterFiles.empty()) {
+ std::string SpecialCaseListErr;
+ NameWhitelist =
+ SpecialCaseList::create(NameFilterFiles, SpecialCaseListErr);
+ if (!NameWhitelist)
+ error(SpecialCaseListErr);
+ }
+
// Create the function filters
- if (!NameFilters.empty() || !NameRegexFilters.empty()) {
+ if (!NameFilters.empty() || NameWhitelist || !NameRegexFilters.empty()) {
auto NameFilterer = llvm::make_unique<CoverageFilters>();
for (const auto &Name : NameFilters)
NameFilterer->push_back(llvm::make_unique<NameCoverageFilter>(Name));
+ if (NameWhitelist)
+ NameFilterer->push_back(
+ llvm::make_unique<NameWhitelistCoverageFilter>(*NameWhitelist));
for (const auto &Regex : NameRegexFilters)
NameFilterer->push_back(
llvm::make_unique<NameRegexCoverageFilter>(Regex));
diff --git a/llvm/tools/llvm-cov/CoverageFilters.cpp b/llvm/tools/llvm-cov/CoverageFilters.cpp
index 325dd723578..606d4af1687 100644
--- a/llvm/tools/llvm-cov/CoverageFilters.cpp
+++ b/llvm/tools/llvm-cov/CoverageFilters.cpp
@@ -27,6 +27,11 @@ NameRegexCoverageFilter::matches(const coverage::FunctionRecord &Function) {
return llvm::Regex(Regex).match(Function.Name);
}
+bool NameWhitelistCoverageFilter::matches(
+ const coverage::FunctionRecord &Function) {
+ return Whitelist.inSection("whitelist_fun", Function.Name);
+}
+
bool RegionCoverageFilter::matches(const coverage::FunctionRecord &Function) {
return PassesThreshold(FunctionCoverageSummary::get(Function)
.RegionCoverage.getPercentCovered());
diff --git a/llvm/tools/llvm-cov/CoverageFilters.h b/llvm/tools/llvm-cov/CoverageFilters.h
index 756c4b47872..e5c52fe877a 100644
--- a/llvm/tools/llvm-cov/CoverageFilters.h
+++ b/llvm/tools/llvm-cov/CoverageFilters.h
@@ -15,6 +15,7 @@
#define LLVM_COV_COVERAGEFILTERS_H
#include "llvm/ProfileData/Coverage/CoverageMapping.h"
+#include "llvm/Support/SpecialCaseList.h"
#include <memory>
#include <vector>
@@ -51,6 +52,18 @@ public:
bool matches(const coverage::FunctionRecord &Function) override;
};
+/// \brief Matches functions whose name appears in a SpecialCaseList in the
+/// whitelist_fun section.
+class NameWhitelistCoverageFilter : public CoverageFilter {
+ const SpecialCaseList &Whitelist;
+
+public:
+ NameWhitelistCoverageFilter(const SpecialCaseList &Whitelist)
+ : Whitelist(Whitelist) {}
+
+ bool matches(const coverage::FunctionRecord &Function) override;
+};
+
/// \brief Matches numbers that pass a certain threshold.
template <typename T> class StatisticThresholdFilter {
public:
OpenPOWER on IntegriCloud