[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;
|
using namespace llvm;
|
||||||
|
|
||||||
bool NameCoverageFilter::matches(const coverage::CoverageMapping &,
|
bool NameCoverageFilter::matches(
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::CoverageMapping &,
|
||||||
|
const coverage::FunctionRecord &Function) const {
|
||||||
StringRef FuncName = Function.Name;
|
StringRef FuncName = Function.Name;
|
||||||
return FuncName.find(Name) != StringRef::npos;
|
return FuncName.find(Name) != StringRef::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NameRegexCoverageFilter::matches(
|
bool NameRegexCoverageFilter::matches(
|
||||||
const coverage::CoverageMapping &,
|
const coverage::CoverageMapping &,
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::FunctionRecord &Function) const {
|
||||||
return llvm::Regex(Regex).match(Function.Name);
|
return llvm::Regex(Regex).match(Function.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NameWhitelistCoverageFilter::matches(
|
bool NameWhitelistCoverageFilter::matches(
|
||||||
const coverage::CoverageMapping &,
|
const coverage::CoverageMapping &,
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::FunctionRecord &Function) const {
|
||||||
return Whitelist.inSection("llvmcov", "whitelist_fun", Function.Name);
|
return Whitelist.inSection("llvmcov", "whitelist_fun", Function.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RegionCoverageFilter::matches(const coverage::CoverageMapping &CM,
|
bool RegionCoverageFilter::matches(
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::CoverageMapping &CM,
|
||||||
|
const coverage::FunctionRecord &Function) const {
|
||||||
return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
|
return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
|
||||||
.RegionCoverage.getPercentCovered());
|
.RegionCoverage.getPercentCovered());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LineCoverageFilter::matches(const coverage::CoverageMapping &CM,
|
bool LineCoverageFilter::matches(
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::CoverageMapping &CM,
|
||||||
|
const coverage::FunctionRecord &Function) const {
|
||||||
return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
|
return PassesThreshold(FunctionCoverageSummary::get(CM, Function)
|
||||||
.LineCoverage.getPercentCovered());
|
.LineCoverage.getPercentCovered());
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +55,7 @@ void CoverageFilters::push_back(std::unique_ptr<CoverageFilter> Filter) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CoverageFilters::matches(const coverage::CoverageMapping &CM,
|
bool CoverageFilters::matches(const coverage::CoverageMapping &CM,
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::FunctionRecord &Function) const {
|
||||||
for (const auto &Filter : Filters) {
|
for (const auto &Filter : Filters) {
|
||||||
if (Filter->matches(CM, Function))
|
if (Filter->matches(CM, Function))
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -62,7 +65,7 @@ bool CoverageFilters::matches(const coverage::CoverageMapping &CM,
|
||||||
|
|
||||||
bool CoverageFiltersMatchAll::matches(
|
bool CoverageFiltersMatchAll::matches(
|
||||||
const coverage::CoverageMapping &CM,
|
const coverage::CoverageMapping &CM,
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::FunctionRecord &Function) const {
|
||||||
for (const auto &Filter : Filters) {
|
for (const auto &Filter : Filters) {
|
||||||
if (!Filter->matches(CM, Function))
|
if (!Filter->matches(CM, Function))
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ public:
|
||||||
|
|
||||||
/// \brief Return true if the function passes the requirements of this filter.
|
/// \brief Return true if the function passes the requirements of this filter.
|
||||||
virtual bool matches(const coverage::CoverageMapping &CM,
|
virtual bool matches(const coverage::CoverageMapping &CM,
|
||||||
const coverage::FunctionRecord &Function) {
|
const coverage::FunctionRecord &Function) const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -42,7 +42,7 @@ public:
|
||||||
NameCoverageFilter(StringRef Name) : Name(Name) {}
|
NameCoverageFilter(StringRef Name) : Name(Name) {}
|
||||||
|
|
||||||
bool matches(const coverage::CoverageMapping &CM,
|
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.
|
/// \brief Matches functions whose name matches a certain regular expression.
|
||||||
|
|
@ -53,7 +53,7 @@ public:
|
||||||
NameRegexCoverageFilter(StringRef Regex) : Regex(Regex) {}
|
NameRegexCoverageFilter(StringRef Regex) : Regex(Regex) {}
|
||||||
|
|
||||||
bool matches(const coverage::CoverageMapping &CM,
|
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
|
/// \brief Matches functions whose name appears in a SpecialCaseList in the
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
: Whitelist(Whitelist) {}
|
: Whitelist(Whitelist) {}
|
||||||
|
|
||||||
bool matches(const coverage::CoverageMapping &CM,
|
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.
|
/// \brief Matches numbers that pass a certain threshold.
|
||||||
|
|
@ -103,7 +103,7 @@ public:
|
||||||
: StatisticThresholdFilter(Op, Threshold) {}
|
: StatisticThresholdFilter(Op, Threshold) {}
|
||||||
|
|
||||||
bool matches(const coverage::CoverageMapping &CM,
|
bool matches(const coverage::CoverageMapping &CM,
|
||||||
const coverage::FunctionRecord &Function) override;
|
const coverage::FunctionRecord &Function) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Matches functions whose line coverage percentage
|
/// \brief Matches functions whose line coverage percentage
|
||||||
|
|
@ -115,7 +115,7 @@ public:
|
||||||
: StatisticThresholdFilter(Op, Threshold) {}
|
: StatisticThresholdFilter(Op, Threshold) {}
|
||||||
|
|
||||||
bool matches(const coverage::CoverageMapping &CM,
|
bool matches(const coverage::CoverageMapping &CM,
|
||||||
const coverage::FunctionRecord &Function) override;
|
const coverage::FunctionRecord &Function) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief A collection of filters.
|
/// \brief A collection of filters.
|
||||||
|
|
@ -132,7 +132,7 @@ public:
|
||||||
bool empty() const { return Filters.empty(); }
|
bool empty() const { return Filters.empty(); }
|
||||||
|
|
||||||
bool matches(const coverage::CoverageMapping &CM,
|
bool matches(const coverage::CoverageMapping &CM,
|
||||||
const coverage::FunctionRecord &Function) override;
|
const coverage::FunctionRecord &Function) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief A collection of filters.
|
/// \brief A collection of filters.
|
||||||
|
|
@ -141,7 +141,7 @@ public:
|
||||||
class CoverageFiltersMatchAll : public CoverageFilters {
|
class CoverageFiltersMatchAll : public CoverageFilters {
|
||||||
public:
|
public:
|
||||||
bool matches(const coverage::CoverageMapping &CM,
|
bool matches(const coverage::CoverageMapping &CM,
|
||||||
const coverage::FunctionRecord &Function) override;
|
const coverage::FunctionRecord &Function) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue