diff options
-rw-r--r-- | llvm/tools/llvm-cov/CoverageFilters.cpp | 23 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/CoverageFilters.h | 16 |
2 files changed, 21 insertions, 18 deletions
diff --git a/llvm/tools/llvm-cov/CoverageFilters.cpp b/llvm/tools/llvm-cov/CoverageFilters.cpp index ce78bb2713c..441179601dc 100644 --- a/llvm/tools/llvm-cov/CoverageFilters.cpp +++ b/llvm/tools/llvm-cov/CoverageFilters.cpp @@ -17,32 +17,35 @@ using namespace llvm; -bool NameCoverageFilter::matches(const coverage::CoverageMapping &, - const coverage::FunctionRecord &Function) { +bool NameCoverageFilter::matches( + const coverage::CoverageMapping &, + const coverage::FunctionRecord &Function) const { StringRef FuncName = Function.Name; return FuncName.find(Name) != StringRef::npos; } bool NameRegexCoverageFilter::matches( const coverage::CoverageMapping &, - const coverage::FunctionRecord &Function) { + const coverage::FunctionRecord &Function) const { return llvm::Regex(Regex).match(Function.Name); } bool NameWhitelistCoverageFilter::matches( const coverage::CoverageMapping &, - const coverage::FunctionRecord &Function) { + const coverage::FunctionRecord &Function) const { return Whitelist.inSection("llvmcov", "whitelist_fun", Function.Name); } -bool RegionCoverageFilter::matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) { +bool RegionCoverageFilter::matches( + const coverage::CoverageMapping &CM, + const coverage::FunctionRecord &Function) const { return PassesThreshold(FunctionCoverageSummary::get(CM, Function) .RegionCoverage.getPercentCovered()); } -bool LineCoverageFilter::matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) { +bool LineCoverageFilter::matches( + const coverage::CoverageMapping &CM, + const coverage::FunctionRecord &Function) const { return PassesThreshold(FunctionCoverageSummary::get(CM, Function) .LineCoverage.getPercentCovered()); } @@ -52,7 +55,7 @@ void CoverageFilters::push_back(std::unique_ptr<CoverageFilter> Filter) { } bool CoverageFilters::matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) { + const coverage::FunctionRecord &Function) const { for (const auto &Filter : Filters) { if (Filter->matches(CM, Function)) return true; @@ -62,7 +65,7 @@ bool CoverageFilters::matches(const coverage::CoverageMapping &CM, bool CoverageFiltersMatchAll::matches( const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) { + const coverage::FunctionRecord &Function) const { for (const auto &Filter : Filters) { if (!Filter->matches(CM, Function)) return false; diff --git a/llvm/tools/llvm-cov/CoverageFilters.h b/llvm/tools/llvm-cov/CoverageFilters.h index 83069fa7321..aeaf61de173 100644 --- a/llvm/tools/llvm-cov/CoverageFilters.h +++ b/llvm/tools/llvm-cov/CoverageFilters.h @@ -29,7 +29,7 @@ public: /// \brief Return true if the function passes the requirements of this filter. virtual bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) { + const coverage::FunctionRecord &Function) const { return true; } }; @@ -42,7 +42,7 @@ public: NameCoverageFilter(StringRef Name) : Name(Name) {} bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) override; + const coverage::FunctionRecord &Function) const override; }; /// \brief Matches functions whose name matches a certain regular expression. @@ -53,7 +53,7 @@ public: NameRegexCoverageFilter(StringRef Regex) : Regex(Regex) {} bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) override; + const coverage::FunctionRecord &Function) const override; }; /// \brief Matches functions whose name appears in a SpecialCaseList in the @@ -66,7 +66,7 @@ public: : Whitelist(Whitelist) {} bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) override; + const coverage::FunctionRecord &Function) const override; }; /// \brief Matches numbers that pass a certain threshold. @@ -103,7 +103,7 @@ public: : StatisticThresholdFilter(Op, Threshold) {} bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) override; + const coverage::FunctionRecord &Function) const override; }; /// \brief Matches functions whose line coverage percentage @@ -115,7 +115,7 @@ public: : StatisticThresholdFilter(Op, Threshold) {} bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) override; + const coverage::FunctionRecord &Function) const override; }; /// \brief A collection of filters. @@ -132,7 +132,7 @@ public: bool empty() const { return Filters.empty(); } bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) override; + const coverage::FunctionRecord &Function) const override; }; /// \brief A collection of filters. @@ -141,7 +141,7 @@ public: class CoverageFiltersMatchAll : public CoverageFilters { public: bool matches(const coverage::CoverageMapping &CM, - const coverage::FunctionRecord &Function) override; + const coverage::FunctionRecord &Function) const override; }; } // namespace llvm |