From 9af7abd106e6e1b1dccdd70125a761b385f653d8 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 25 Oct 2023 19:43:29 +0200 Subject: [analysis][NFC] Rename `makeLeastUpperBound` to `join` and move it to lattice (#6035) In general, the operation of taking the least upper bound of two lattice elements may depend on some state stored in the lattice object rather than in the elements themselves. To avoid forcing the elements to be larger and more complicated in that case (by storing a parent pointer back to the lattice), move the least upper bound operation to make it a method of the lattice rather than the lattice element. This is also more consistent with where we put e.g. the `compare` method. While we are at it, rename `makeLeastUpperBound` to `join`, which is much shorter and nicer. Usually we avoid using esoteric mathematical jargon like this, but "join" as a normal verb actually describes the operation nicely, so I think it is ok in this case. --- src/analysis/lattice.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/analysis/lattice.h') diff --git a/src/analysis/lattice.h b/src/analysis/lattice.h index 7865de20b..ab75e0829 100644 --- a/src/analysis/lattice.h +++ b/src/analysis/lattice.h @@ -46,16 +46,17 @@ concept Lattice = requires(const L& lattice, // Lattices must have elements. typename L::Element; requires std::copyable; - // We need to be able to get the bottom element. + // Get the bottom element of this lattice. { lattice.getBottom() } noexcept -> std::same_as; - // Elements should be comparable. TODO: use <=> and std::three_way_comparable - // once we support C++20 everywhere. + // Compare two elements of this lattice. TODO: use <=> and + // std::three_way_comparable once we support C++20 everywhere. { lattice.compare(constElem, constElem) } noexcept -> std::same_as; - // We need to be able to get the least upper bound of two elements and know - // whether any change was made. - { elem.makeLeastUpperBound(constElem) } noexcept -> std::same_as; + // Modify `elem` in-place to be the join (aka least upper bound) of `elem` and + // `constElem`, returning true iff `elem` was modified, i.e. if it was not + // already an upper bound of `constElem`. + { lattice.join(elem, constElem) } noexcept -> std::same_as; }; #else // __cplusplus >= 202002L -- cgit v1.2.3