1 //===- CoverageFilters.cpp - Function coverage mapping filters ------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // These classes provide filtering for function coverage mapping records.
12 //===----------------------------------------------------------------------===//
14 #include "CoverageFilters.h"
15 #include "CoverageSummaryInfo.h"
16 #include "llvm/Support/Regex.h"
20 bool NameCoverageFilter::matches(const coverage::FunctionRecord &Function) {
21 StringRef FuncName = Function.Name;
22 return FuncName.find(Name) != StringRef::npos;
26 NameRegexCoverageFilter::matches(const coverage::FunctionRecord &Function) {
27 return llvm::Regex(Regex).match(Function.Name);
30 bool RegionCoverageFilter::matches(const coverage::FunctionRecord &Function) {
31 return PassesThreshold(FunctionCoverageSummary::get(Function)
32 .RegionCoverage.getPercentCovered());
35 bool LineCoverageFilter::matches(const coverage::FunctionRecord &Function) {
36 return PassesThreshold(
37 FunctionCoverageSummary::get(Function).LineCoverage.getPercentCovered());
40 void CoverageFilters::push_back(std::unique_ptr<CoverageFilter> Filter) {
41 Filters.push_back(std::move(Filter));
44 bool CoverageFilters::matches(const coverage::FunctionRecord &Function) {
45 for (const auto &Filter : Filters) {
46 if (Filter->matches(Function))
53 CoverageFiltersMatchAll::matches(const coverage::FunctionRecord &Function) {
54 for (const auto &Filter : Filters) {
55 if (!Filter->matches(Function))