Coverage Report

Created: 2017-09-21 03:39

/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(const coverage::CoverageMapping &,
21
17
                                 const coverage::FunctionRecord &Function) {
22
17
  StringRef FuncName = Function.Name;
23
17
  return FuncName.find(Name) != StringRef::npos;
24
17
}
25
26
bool NameRegexCoverageFilter::matches(
27
    const coverage::CoverageMapping &,
28
7
    const coverage::FunctionRecord &Function) {
29
7
  return llvm::Regex(Regex).match(Function.Name);
30
7
}
31
32
bool NameWhitelistCoverageFilter::matches(
33
    const coverage::CoverageMapping &,
34
14
    const coverage::FunctionRecord &Function) {
35
14
  return Whitelist.inSection("whitelist_fun", Function.Name);
36
14
}
37
38
bool RegionCoverageFilter::matches(const coverage::CoverageMapping &CM,
39
0
                                   const coverage::FunctionRecord &Function) {
40
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
41
0
                             .RegionCoverage.getPercentCovered());
42
0
}
43
44
bool LineCoverageFilter::matches(const coverage::CoverageMapping &CM,
45
0
                                 const coverage::FunctionRecord &Function) {
46
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
47
0
                             .LineCoverage.getPercentCovered());
48
0
}
49
50
28
void CoverageFilters::push_back(std::unique_ptr<CoverageFilter> Filter) {
51
28
  Filters.push_back(std::move(Filter));
52
28
}
53
54
bool CoverageFilters::matches(const coverage::CoverageMapping &CM,
55
38
                              const coverage::FunctionRecord &Function) {
56
38
  for (const auto &Filter : Filters) {
57
38
    if (Filter->matches(CM, Function))
58
21
      return true;
59
17
  }
60
17
  return false;
61
17
}
62
63
bool CoverageFiltersMatchAll::matches(
64
    const coverage::CoverageMapping &CM,
65
38
    const coverage::FunctionRecord &Function) {
66
38
  for (const auto &Filter : Filters) {
67
38
    if (!Filter->matches(CM, Function))
68
17
      return false;
69
21
  }
70
21
  return true;
71
21
}