Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/llvm-cov/CoverageFilters.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- CoverageFilters.cpp - Function coverage mapping filters ------------===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// These classes provide filtering for function coverage mapping records.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "CoverageFilters.h"
15
#include "CoverageSummaryInfo.h"
16
#include "llvm/Support/Regex.h"
17
18
using namespace llvm;
19
20
bool NameCoverageFilter::matches(
21
    const coverage::CoverageMapping &,
22
66
    const coverage::FunctionRecord &Function) const {
23
66
  StringRef FuncName = Function.Name;
24
66
  return FuncName.find(Name) != StringRef::npos;
25
66
}
26
27
bool NameRegexCoverageFilter::matches(
28
    const coverage::CoverageMapping &,
29
11
    const coverage::FunctionRecord &Function) const {
30
11
  return llvm::Regex(Regex).match(Function.Name);
31
11
}
32
33
bool NameWhitelistCoverageFilter::matches(
34
    const coverage::CoverageMapping &,
35
12
    const coverage::FunctionRecord &Function) const {
36
12
  return Whitelist.inSection("llvmcov", "whitelist_fun", Function.Name);
37
12
}
38
39
bool RegionCoverageFilter::matches(
40
    const coverage::CoverageMapping &CM,
41
0
    const coverage::FunctionRecord &Function) const {
42
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
43
0
                             .RegionCoverage.getPercentCovered());
44
0
}
45
46
bool LineCoverageFilter::matches(
47
    const coverage::CoverageMapping &CM,
48
0
    const coverage::FunctionRecord &Function) const {
49
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
50
0
                             .LineCoverage.getPercentCovered());
51
0
}
52
53
40
void CoverageFilters::push_back(std::unique_ptr<CoverageFilter> Filter) {
54
40
  Filters.push_back(std::move(Filter));
55
40
}
56
57
bool CoverageFilters::matches(const coverage::CoverageMapping &CM,
58
73
                              const coverage::FunctionRecord &Function) const {
59
89
  for (const auto &Filter : Filters) {
60
89
    if (Filter->matches(CM, Function))
61
42
      return true;
62
31
  }
63
31
  return false;
64
31
}
65
66
bool CoverageFiltersMatchAll::matches(
67
    const coverage::CoverageMapping &CM,
68
150
    const coverage::FunctionRecord &Function) const {
69
73
  for (const auto &Filter : Filters) {
70
73
    if (!Filter->matches(CM, Function))
71
31
      return false;
72
119
  }
73
119
  return true;
74
119
}