diff options
author | Thomas Lively <tlively@google.com> | 2023-10-19 07:41:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-18 22:41:53 -0700 |
commit | f79b5aa26b1fc722853e56b541cd35128786ef6b (patch) | |
tree | 0a8255cb2a3d2c4f1ee41dcb64cbcce4758f4341 /src/analysis/stack-lattice.h | |
parent | c170fe7893fc05147de455e36d0a36b356b3f3db (diff) | |
download | binaryen-f79b5aa26b1fc722853e56b541cd35128786ef6b.tar.gz binaryen-f79b5aa26b1fc722853e56b541cd35128786ef6b.tar.bz2 binaryen-f79b5aa26b1fc722853e56b541cd35128786ef6b.zip |
[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.
Diffstat (limited to 'src/analysis/stack-lattice.h')
-rw-r--r-- | src/analysis/stack-lattice.h | 10 |
1 files changed, 5 insertions, 5 deletions
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<typename StackElementLattice> class StackLattice { - static_assert(is_lattice<StackElementLattice>); +template<Lattice StackElementLattice> 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 |