From f79b5aa26b1fc722853e56b541cd35128786ef6b Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Thu, 19 Oct 2023 07:41:53 +0200 Subject: [analysis][NFC] Use C++20 concepts for Lattice (#6027) Replace the static assertions ensuring that Lattice types have the necessary operations with a C++20 concept called `Lattice`. To avoid name conflicts with the new concept, rename existing type parameters named `Lattice` to `L`. When not building with C++20, `Lattice` is a macro that resolves to `typename` so the code continues compiling and has the same behavior, but without any eager checks of the requirements on lattices. Add a new C++20 builder to CI to ensure that future changes compile with both C++17 and C++20. Once we switch to C++20 by default, the new builder can be removed. Update the lint builder to use a recent clang-format that understands concepts. --- src/analysis/stack-lattice.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/analysis/stack-lattice.h') diff --git a/src/analysis/stack-lattice.h b/src/analysis/stack-lattice.h index 069dfa8ab..e27e01a2f 100644 --- a/src/analysis/stack-lattice.h +++ b/src/analysis/stack-lattice.h @@ -65,8 +65,7 @@ namespace wasm::analysis { // produce a stack [b, LUB(a, a')], where LUB(a, a') takes the maximum // of the two maximum bit values. -template class StackLattice { - static_assert(is_lattice); +template class StackLattice { StackElementLattice& stackElementLattice; public: @@ -127,7 +126,7 @@ public: // fits with the conception of the stack starting at the top and having // an infinite bottom, which allows stacks of different height and scope // to be easily joined. - bool makeLeastUpperBound(const Element& other) { + bool makeLeastUpperBound(const Element& other) noexcept { // Top element cases, since top elements don't actually have the stack // value. if (isTop()) { @@ -185,7 +184,8 @@ public: // >= right top or if the left stack is higher and the right top > left top or // they are unrelated, then there is no relation. Same applies for the reverse // relationship. - LatticeComparison compare(const Element& left, const Element& right) { + LatticeComparison compare(const Element& left, + const Element& right) const noexcept { // Handle cases where there are top elements. if (left.isTop()) { if (right.isTop()) { @@ -246,7 +246,7 @@ public: } } - Element getBottom() { return Element{}; } + Element getBottom() const noexcept { return Element{}; } }; } // namespace wasm::analysis -- cgit v1.2.3