[llvm] r314281 - [llvm-cov] Improve const-correctness of filters. NFC.

Sean Eveson via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 01:32:36 PDT 2017


Author: seaneveson
Date: Wed Sep 27 01:32:36 2017
New Revision: 314281

URL: http://llvm.org/viewvc/llvm-project?rev=314281&view=rev
Log:
[llvm-cov] Improve const-correctness of filters. NFC.

Modified:
    llvm/trunk/tools/llvm-cov/CoverageFilters.cpp
    llvm/trunk/tools/llvm-cov/CoverageFilters.h

Modified: llvm/trunk/tools/llvm-cov/CoverageFilters.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageFilters.cpp?rev=314281&r1=314280&r2=314281&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageFilters.cpp (original)
+++ llvm/trunk/tools/llvm-cov/CoverageFilters.cpp Wed Sep 27 01:32:36 2017
@@ -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::uni
 }
 
 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 cove
 
 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;

Modified: llvm/trunk/tools/llvm-cov/CoverageFilters.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CoverageFilters.h?rev=314281&r1=314280&r2=314281&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/CoverageFilters.h (original)
+++ llvm/trunk/tools/llvm-cov/CoverageFilters.h Wed Sep 27 01:32:36 2017
@@ -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




More information about the llvm-commits mailing list