clang: include/clang/Analysis/FlowSensitive/MapLattice.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE__MAPLATTICE_H
16#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE__MAPLATTICE_H
17
18#include
19#include
20#include
21
25#include "llvm/ADT/DenseMap.h"
26#include "llvm/ADT/StringRef.h"
27
29namespace dataflow {
30
31
32
33
34
35
36
37
38
39template <typename Key, typename ElementLattice> class MapLattice {
40 using Container = llvm::DenseMap<Key, ElementLattice>;
41 Container C;
42
43public:
46 using value_type = typename Container::value_type;
47 using iterator = typename Container::iterator;
49
51
53
54
56
57 std::pair<iterator, bool>
58 insert(const std::pair<const key_type, mapped_type> &P) {
59 return C.insert(P);
60 }
61
62 std::pair<iterator, bool> insert(std::pair<const key_type, mapped_type> &&P) {
63 return C.insert(std::move(P));
64 }
65
66 unsigned size() const { return C.size(); }
67 bool empty() const { return C.empty(); }
68
73
74
75
76
78 return LHS.C == RHS.C;
79 }
80
82 return !(LHS == RHS);
83 }
84
85 bool contains(const key_type &K) const { return C.find(K) != C.end(); }
86
89
91
92
93
94
97 for (const auto &O : Other.C) {
98 auto It = C.find(O.first);
99 if (It == C.end()) {
100 C.insert(O);
104 }
105 return Effect;
106 }
107};
108
109
110
111template
113
114template <typename Key, typename ElementLattice>
115std::ostream &
118 std::string Separator;
119 Os << "{";
120 for (const auto &E : M) {
121 Os << std::exchange(Separator, ", ") << E.first << " => " << E.second;
122 }
123 Os << "}";
124 return Os;
125}
126
127template
128std::ostream &
131 std::string Separator;
132 Os << "{";
133 for (const auto &E : M) {
134 Os << std::exchange(Separator, ", ") << E.first->getName().str() << " => "
135 << E.second;
136 }
137 Os << "}";
138 return Os;
139}
140}
141}
142
143#endif
A lattice that maps keys to individual lattice elements.
typename Container::iterator iterator
bool contains(const key_type &K) const
mapped_type & operator[](const key_type &K)
const_iterator end() const
const_iterator find(const key_type &K) const
typename Container::const_iterator const_iterator
ElementLattice mapped_type
const_iterator begin() const
iterator find(const key_type &K)
friend bool operator!=(const MapLattice &LHS, const MapLattice &RHS)
std::pair< iterator, bool > insert(std::pair< const key_type, mapped_type > &&P)
std::pair< iterator, bool > insert(const std::pair< const key_type, mapped_type > &P)
LatticeJoinEffect join(const MapLattice &Other)
If an entry exists in one map but not the other, the missing entry is treated as implicitly mapping t...
friend bool operator==(const MapLattice &LHS, const MapLattice &RHS)
static MapLattice bottom()
typename Container::value_type value_type
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, Atom A)
LatticeEffect
Effect indicating whether a lattice operation resulted in a new value.
The JSON file list parser is used to communicate input to InstallAPI.
@ Other
Other implicit parameter.