Skip to content

Commit 5618d21

Browse files
authored
[analysis][NFC] Refactor lattice unit tests (#6065)
Many of the lattice tests were essentially copy-pasted from one lattice to the next because they all tested isomorphic subsets of the various lattices, specifically in the shape of a diamond. Refactor the code so that all lattices that have tests of this shape use the same utility test functions.
1 parent 74237bf commit 5618d21

File tree

2 files changed

+152
-420
lines changed

2 files changed

+152
-420
lines changed

src/analysis/lattices/flat.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ struct Flat {
5151
bool isTop() const noexcept { return std::get_if<Top>(this); }
5252
const T* getVal() const noexcept { return std::get_if<T>(this); }
5353
T* getVal() noexcept { return std::get_if<T>(this); }
54+
bool operator==(const Element& other) const noexcept {
55+
return ((isBottom() && other.isBottom()) || (isTop() && other.isTop()) ||
56+
(getVal() && other.getVal() && *getVal() == *other.getVal()));
57+
}
58+
bool operator!=(const Element& other) const noexcept {
59+
return !(*this == other);
60+
}
5461
};
5562

5663
Element getBottom() const noexcept { return Element{Bot{}}; }

0 commit comments

Comments
 (0)