Coverage Report

Created: 2019-05-19 14:56

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// These classes provide filtering for function coverage mapping records.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "CoverageFilters.h"
14
#include "CoverageSummaryInfo.h"
15
#include "llvm/Support/Regex.h"
16
17
using namespace llvm;
18
19
bool NameCoverageFilter::matches(
20
    const coverage::CoverageMapping &,
21
81
    const coverage::FunctionRecord &Function) const {
22
81
  StringRef FuncName = Function.Name;
23
81
  return FuncName.find(Name) != StringRef::npos;
24
81
}
25
26
bool NameRegexCoverageFilter::matches(
27
    const coverage::CoverageMapping &,
28
11
    const coverage::FunctionRecord &Function) const {
29
11
  return llvm::Regex(Regex).match(Function.Name);
30
11
}
31
32
19
bool NameRegexCoverageFilter::matchesFilename(StringRef Filename) const {
33
19
  return llvm::Regex(Regex).match(Filename);
34
19
}
35
36
bool NameWhitelistCoverageFilter::matches(
37
    const coverage::CoverageMapping &,
38
12
    const coverage::FunctionRecord &Function) const {
39
12
  return Whitelist.inSection("llvmcov", "whitelist_fun", Function.Name);
40
12
}
41
42
bool RegionCoverageFilter::matches(
43
    const coverage::CoverageMapping &CM,
44
0
    const coverage::FunctionRecord &Function) const {
45
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
46
0
                             .RegionCoverage.getPercentCovered());
47
0
}
48
49
bool LineCoverageFilter::matches(
50
    const coverage::CoverageMapping &CM,
51
0
    const coverage::FunctionRecord &Function) const {
52
0
  return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
53
0
                             .LineCoverage.getPercentCovered());
54
0
}
55
56
49
void CoverageFilters::push_back(std::unique_ptr<CoverageFilter> Filter) {
57
49
  Filters.push_back(std::move(Filter));
58
49
}
59
60
bool CoverageFilters::matches(const coverage::CoverageMapping &CM,
61
90
                              const coverage::FunctionRecord &Function) const {
62
106
  for (const auto &Filter : Filters) {
63
106
    if (Filter->matches(CM, Function))
64
47
      return true;
65
106
  }
66
90
  
return false43
;
67
90
}
68
69
250
bool CoverageFilters::matchesFilename(StringRef Filename) const {
70
250
  for (const auto &Filter : Filters) {
71
19
    if (Filter->matchesFilename(Filename))
72
11
      return true;
73
19
  }
74
250
  
return false239
;
75
250
}
76
77
bool CoverageFiltersMatchAll::matches(
78
    const coverage::CoverageMapping &CM,
79
262
    const coverage::FunctionRecord &Function) const {
80
262
  for (const auto &Filter : Filters) {
81
90
    if (!Filter->matches(CM, Function))
82
43
      return false;
83
90
  }
84
262
  
return true219
;
85
262
}