forked from OSchip/llvm-project
[llvm-cov] Improve const-correctness of filters. NFC.
llvm-svn: 314281
This commit is contained in:
parent
211f47aa37
commit
25ea19ea86
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue