-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStructElement.hh
More file actions
41 lines (26 loc) · 970 Bytes
/
StructElement.hh
File metadata and controls
41 lines (26 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef INCLUDE_STRUCT_ELEMENT_HH
#define INCLUDE_STRUCT_ELEMENT_HH
#include <boost/optional.hpp>
#include <llvm/IR/DerivedTypes.h>
class StructElement {
public:
StructElement(const llvm::StructType &, unsigned);
static boost::optional<StructElement> get(const llvm::Value &);
const llvm::StructType &structure;
unsigned index;
};
bool operator<(const StructElement &, const StructElement &);
llvm::raw_ostream &operator<<(llvm::raw_ostream &, const StructElement &);
////////////////////////////////////////////////////////////////////////
inline StructElement::StructElement(const llvm::StructType &structure, unsigned index)
: structure(structure),
index(index)
{
}
inline bool operator<(const StructElement &a, const StructElement &b)
{
const auto aFieldwise = std::make_pair(&a.structure, a.index);
const auto bFieldwise = std::make_pair(&b.structure, b.index);
return aFieldwise < bFieldwise;
}
#endif // !INCLUDE_FIND_STRUCT_ELEMENTS_HH