Coverage Report

Created: 2018-06-18 20:01

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/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
82
    const coverage::FunctionRecord &Function) const {
23
82
  StringRef FuncName = Function.Name;
24
82
  return FuncName.find(Name) != StringRef::npos;
25
82
}
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
19
bool NameRegexCoverageFilter::matchesFilename(StringRef Filename) const {
34
19
  return llvm::Regex(Regex).match(Filename);
35
19
}
36
37
bool NameWhitelistCoverageFilter::matches(
38
    const coverage::CoverageMapping &,
39
12
    const coverage::FunctionRecord &Function) const {
40
12
  return Whitelist.inSection("llvmcov", "whitelist_fun", Function.Name);
41
12
}
42
43
bool RegionCoverageFilter::matches(
44
    const coverage::CoverageMapping &CM,
45
0
    const coverage::FunctionRecord &Function) const {
46
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
47
0
                             .RegionCoverage.getPercentCovered());
48
0
}
49
50
bool LineCoverageFilter::matches(
51
    const coverage::CoverageMapping &CM,
52
0
    const coverage::FunctionRecord &Function) const {
53
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
54
0
                             .LineCoverage.getPercentCovered());
55
0
}
56
57
51
void CoverageFilters::push_back(std::unique_ptr<CoverageFilter> Filter) {
58
51
  Filters.push_back(std::move(Filter));
59
51
}
60
61
bool CoverageFilters::matches(const coverage::CoverageMapping &CM,
62
90
                              const coverage::FunctionRecord &Function) const {
63
106
  for (const auto &Filter : Filters) {
64
106
    if (Filter->matches(CM, Function))
65
47
      return true;
66
106
  }
67
90
  
return false43
;
68
90
}
69
70
249
bool CoverageFilters::matchesFilename(StringRef Filename) const {
71
249
  for (const auto &Filter : Filters) {
72
19
    if (Filter->matchesFilename(Filename))
73
11
      return true;
74
19
  }
75
249
  
return false238
;
76
249
}
77
78
bool CoverageFiltersMatchAll::matches(
79
    const coverage::CoverageMapping &CM,
80
260
    const coverage::FunctionRecord &Function) const {
81
260
  for (const auto &Filter : Filters) {
82
90
    if (!Filter->matches(CM, Function))
83
43
      return false;
84
90
  }
85
260
  
return true217
;
86
260
}