Skip to content

Commit 926bb34

Browse files
committed
reduce pitfalls
1 parent 02e5465 commit 926bb34

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Solver/SolverResults.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <map>
2121
#include <set>
22+
#include <type_traits>
2223
#include <unordered_map>
2324

2425
#include <phasar/PhasarLLVM/Utils/BinaryDomain.h>
@@ -35,7 +36,7 @@ template <typename N, typename D, typename L> class SolverResults {
3536
SolverResults(Table<N, D, L> &res_tab, D zv)
3637
: results(res_tab), zeroValue(zv) {}
3738

38-
L valueAt(N stmt, D node) const { return results.get(stmt, node); }
39+
L resultAt(N stmt, D node) const { return results.get(stmt, node); }
3940

4041
std::unordered_map<D, L> resultsAt(N stmt, bool stripZero = false) const {
4142
std::unordered_map<D, L> result = results.row(stmt);
@@ -51,13 +52,18 @@ template <typename N, typename D, typename L> class SolverResults {
5152
return result;
5253
}
5354

55+
// this function only exists for IFDS problems which use BinaryDomain as their
56+
// value domain L
57+
template <typename ValueDomain = L,
58+
typename = typename std::enable_if_t<
59+
std::is_same_v<ValueDomain, BinaryDomain>>>
5460
std::set<D> ifdsResultsAt(N stmt) const {
55-
std::set<D> keyset;
56-
std::unordered_map<D, BinaryDomain> map = this->resultsAt(stmt);
57-
for (auto d : map) {
58-
keyset.insert(d.first);
61+
std::set<D> KeySet;
62+
std::unordered_map<D, BinaryDomain> ResultMap = this->resultsAt(stmt);
63+
for (auto FlowFact : ResultMap) {
64+
KeySet.insert(FlowFact.first);
5965
}
60-
return keyset;
66+
return KeySet;
6167
}
6268
};
6369

include/phasar/Utils/BitVectorSet.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ template <typename T> class BitVectorSet {
209209
return !(Lhs == Rhs);
210210
}
211211

212+
friend bool operator<(const BitVectorSet &Lhs, const BitVectorSet &Rhs) {
213+
return Lhs.Bits < Rhs.Bits;
214+
}
215+
212216
friend std::ostream &operator<<(std::ostream &OS, const BitVectorSet &B) {
213217
OS << '<';
214218
for (auto &Position : B.Position.left) {

0 commit comments

Comments
 (0)