Skip to content

[analysis][NFC] Rename parameters to join and meet methods #6056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/analysis/lattices/bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ struct Bool {
LatticeComparison compare(Element a, Element b) const noexcept {
return a > b ? GREATER : a == b ? EQUAL : LESS;
}
bool join(Element& self, Element other) const noexcept {
if (!self && other) {
self = other;
bool join(Element& joinee, Element joiner) const noexcept {
if (!joinee && joiner) {
joinee = joiner;
return true;
}
return false;
}
bool meet(Element& self, Element other) const noexcept {
if (self && !other) {
self = other;
bool meet(Element& meetee, Element meeter) const noexcept {
if (meetee && !meeter) {
meetee = meeter;
return true;
}
return false;
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/lattices/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ struct Flat {
}
}

bool join(Element& self, const Element& other) const noexcept {
switch (compare(self, other)) {
bool join(Element& joinee, const Element& joiner) const noexcept {
switch (compare(joinee, joiner)) {
case LESS:
self = other;
joinee = joiner;
return true;
case NO_RELATION:
self = Element{Top{}};
joinee = Element{Top{}};
return true;
case GREATER:
case EQUAL:
Expand Down
12 changes: 6 additions & 6 deletions src/analysis/lattices/int.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ struct Integer {
LatticeComparison compare(Element a, Element b) const noexcept {
return a > b ? GREATER : a == b ? EQUAL : LESS;
}
bool join(Element& self, Element other) const noexcept {
if (self < other) {
self = other;
bool join(Element& joinee, Element joiner) const noexcept {
if (joinee < joiner) {
joinee = joiner;
return true;
}
return false;
}
bool meet(Element& self, Element other) const noexcept {
if (self > other) {
self = other;
bool meet(Element& meetee, Element meeter) const noexcept {
if (meetee > meeter) {
meetee = meeter;
return true;
}
return false;
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/lattices/inverted.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ template<FullLattice L> struct Inverted {
LatticeComparison compare(const Element& a, const Element& b) const noexcept {
return lattice.compare(b, a);
}
bool join(Element& self, Element other) const noexcept {
return lattice.meet(self, other);
bool join(Element& joinee, Element joiner) const noexcept {
return lattice.meet(joinee, joiner);
}
bool meet(Element& self, Element other) const noexcept {
return lattice.join(self, other);
bool meet(Element& meetee, Element meeter) const noexcept {
return lattice.join(meetee, meeter);
}
};

Expand Down
12 changes: 6 additions & 6 deletions src/analysis/lattices/lift.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ template<Lattice L> struct Lift {
}
}

bool join(Element& self, const Element& other) const noexcept {
if (self.isBottom() && other.isBottom()) {
bool join(Element& joinee, const Element& joiner) const noexcept {
if (joinee.isBottom() && joiner.isBottom()) {
return false;
} else if (self.isBottom()) {
self = other;
} else if (joinee.isBottom()) {
joinee = joiner;
return true;
} else if (other.isBottom()) {
} else if (joiner.isBottom()) {
return false;
} else {
return lattice.join(*self, *other);
return lattice.join(*joinee, *joiner);
}
}
};
Expand Down
16 changes: 8 additions & 8 deletions src/analysis/lattices/powerset-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ inline size_t FiniteIntPowersetLattice::Element::count() const {
// both sides. We return true if a bit is flipped in-place on the left so the
// worklist algorithm will know if when to enqueue more work.
inline bool
FiniteIntPowersetLattice::join(Element& self,
const Element& other) const noexcept {
FiniteIntPowersetLattice::join(Element& joinee,
const Element& joiner) const noexcept {
// Both must be from powerset lattice of the same set.
assert(other.bitvector.size() == self.bitvector.size());
assert(joiner.bitvector.size() == joinee.bitvector.size());

bool modified = false;
for (size_t i = 0; i < self.bitvector.size(); ++i) {
// Bit is flipped on self only if self is false and other is true when self
// and other are OR'ed together.
modified |= (!self.bitvector[i] && other.bitvector[i]);
self.bitvector[i] = self.bitvector[i] || other.bitvector[i];
for (size_t i = 0; i < joinee.bitvector.size(); ++i) {
// Bit is flipped on joinee only if joinee is false and joiner is true when
// joinee and joiner are OR'ed together.
modified |= (!joinee.bitvector[i] && joiner.bitvector[i]);
joinee.bitvector[i] = joinee.bitvector[i] || joiner.bitvector[i];
}

return modified;
Expand Down
12 changes: 6 additions & 6 deletions src/analysis/lattices/powerset.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ class FiniteIntPowersetLattice {
// Returns an instance of the bottom lattice element.
Element getBottom() const noexcept;

// Modifies `self` to be the join (aka least upper bound) of `self` and
// `other`. Returns true if `self` was modified, i.e. if it was not already an
// upper bound of `other`.
bool join(Element& self, const Element& other) const noexcept;
// Modifies `joinee` to be the join (aka least upper bound) of `joinee` and
// `joiner`. Returns true if `joinee` was modified, i.e. if it was not already
// an upper bound of `joiner`.
bool join(Element& joinee, const Element& joiner) const noexcept;
};

// A layer of abstraction over FiniteIntPowersetLattice which maps
Expand Down Expand Up @@ -150,8 +150,8 @@ template<typename T> class FinitePowersetLattice {

Element getBottom() const noexcept { return intLattice.getBottom(); }

bool join(Element& self, const Element& other) const noexcept {
return intLattice.join(self, other);
bool join(Element& joinee, const Element& joiner) const noexcept {
return intLattice.join(joinee, joiner);
}
};

Expand Down
48 changes: 24 additions & 24 deletions src/analysis/lattices/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,25 +215,25 @@ template<Lattice L> class StackLattice {
}
}

// When taking the LUB, we take the LUBs of the elements of each stack
// starting from the top of the stack. So, LUB([b, a], [b', a']) is
// [LUB(b, b'), LUB(a, a')]. If one stack is higher than the other,
// the bottom of the higher stack will be kept, while the LUB of the
// corresponding tops of each stack will be taken. For instance,
// LUB([d, c, b, a], [b', a']) is [d, c, LUB(b, b'), LUB(a, a')].
// When taking the join, we take the joins of the elements of each stack
// starting from the top of the stack. So, join([b, a], [b', a']) is [join(b,
// b'), join(a, a')]. If one stack is higher than the other, the bottom of the
// higher stack will be kept, while the join of the corresponding tops of each
// stack will be taken. For instance, join([d, c, b, a], [b', a']) is [d, c,
// join(b, b'), join(a, a')].
//
// We start at the top because it makes taking the LUB of stacks with
// different scope easier, as mentioned at the top of the file. It also
// 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 join(Element& self, const Element& other) const noexcept {
// We start at the top because it makes taking the join of stacks with
// different scope easier, as mentioned at the top of the file. It also 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 join(Element& joinee, const Element& joiner) const noexcept {
// Top element cases, since top elements don't actually have the stack
// value.
if (self.isTop()) {
if (joinee.isTop()) {
return false;
} else if (other.isTop()) {
self.stackValue.reset();
} else if (joiner.isTop()) {
joinee.stackValue.reset();
return true;
}

Expand All @@ -242,18 +242,18 @@ template<Lattice L> class StackLattice {
// Merge the shorter height stack with the top of the longer height
// stack. We do this by taking the LUB of each pair of matching elements
// from both stacks.
auto selfIt = self.stackValue->rbegin();
auto otherIt = other.stackValue->crbegin();
for (; selfIt != self.stackValue->rend() &&
otherIt != other.stackValue->crend();
++selfIt, ++otherIt) {
modified |= lattice.join(*selfIt, *otherIt);
auto joineeIt = joinee.stackValue->rbegin();
auto joinerIt = joiner.stackValue->crbegin();
for (; joineeIt != joinee.stackValue->rend() &&
joinerIt != joiner.stackValue->crend();
++joineeIt, ++joinerIt) {
modified |= lattice.join(*joineeIt, *joinerIt);
}

// If the other stack is higher, append the bottom of it to our current
// If the joiner stack is higher, append the bottom of it to our current
// stack.
for (; otherIt != other.stackValue->crend(); ++otherIt) {
self.stackValue->push_front(*otherIt);
for (; joinerIt != joiner.stackValue->crend(); ++joinerIt) {
joinee.stackValue->push_front(*joinerIt);
modified = true;
}

Expand Down