diff options
author | Bruce He <44327446+zm2he@users.noreply.github.com> | 2023-07-28 15:40:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-28 11:40:28 -0400 |
commit | b1e23ca6a1b930421279141ed06e94300eddcf17 (patch) | |
tree | ccf92e6da2c0df5948418fd8d9b6fd13700e0283 | |
parent | 8375f80fa789afaac58b0c86ba5c9396c2003635 (diff) | |
download | binaryen-b1e23ca6a1b930421279141ed06e94300eddcf17.tar.gz binaryen-b1e23ca6a1b930421279141ed06e94300eddcf17.tar.bz2 binaryen-b1e23ca6a1b930421279141ed06e94300eddcf17.zip |
Convert lattice compare function to non-static (#5848)
Changes the static asserts checking a lattice type to require a non-static
compare function instead of a static one. Also changes the compare
functions of existing lattices to be non-static.
-rw-r--r-- | src/analysis/lattice.h | 9 | ||||
-rw-r--r-- | test/gtest/cfg.cpp | 5 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/analysis/lattice.h b/src/analysis/lattice.h index a5c7047dd..cd634c09c 100644 --- a/src/analysis/lattice.h +++ b/src/analysis/lattice.h @@ -31,7 +31,8 @@ constexpr bool has_getBottom = template<typename Lattice> constexpr bool has_compare = std::is_invocable_r<LatticeComparison, - decltype(Lattice::compare), + decltype(&Lattice::compare), + Lattice, const typename Lattice::Element&, const typename Lattice::Element&>::value; template<typename Element> @@ -110,7 +111,7 @@ public: // Compares two lattice elements and returns a result indicating the // left element's relation to the right element. - static LatticeComparison compare(const Element& left, const Element& right); + LatticeComparison compare(const Element& left, const Element& right); // Returns an instance of the bottom lattice element. Element getBottom(); @@ -168,8 +169,8 @@ public: } // We use implementations from FiniteIntPowersetLattice here. - static LatticeComparison compare(const Element& left, const Element& right) { - return FiniteIntPowersetLattice::compare(left, right); + LatticeComparison compare(const Element& left, const Element& right) { + return intLattice.compare(left, right); } Element getBottom() { return intLattice.getBottom(); } diff --git a/test/gtest/cfg.cpp b/test/gtest/cfg.cpp index 7bf18ebdb..07b44e261 100644 --- a/test/gtest/cfg.cpp +++ b/test/gtest/cfg.cpp @@ -320,10 +320,9 @@ TEST_F(CFGTest, FinitePowersetLatticeFunctioning) { auto element2 = element1; lattice.remove(&element2, "c"); - EXPECT_EQ(FinitePowersetLattice<std::string>::compare(element1, element2), - LatticeComparison::GREATER); + EXPECT_EQ(lattice.compare(element1, element2), LatticeComparison::GREATER); lattice.add(&element2, "f"); - EXPECT_EQ(FinitePowersetLattice<std::string>::compare(element1, element2), + EXPECT_EQ(lattice.compare(element1, element2), LatticeComparison::NO_RELATION); std::stringstream ss; |