LLVM: include/llvm/ADT/StringMapEntry.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#ifndef LLVM_ADT_STRINGMAPENTRY_H
17#define LLVM_ADT_STRINGMAPENTRY_H
18
20#include
21
22namespace llvm {
23
24
26
27
29 size_t keyLength;
30
31public:
33
35
36protected:
37
38
39
40 template
41 static void *allocateWithKey(size_t EntrySize, size_t EntryAlign,
43};
44
45
46template
50 size_t KeyLength = Key.size();
51
52
53
54 size_t AllocSize = EntrySize + KeyLength + 1;
55 void *Allocation = Allocator.Allocate(AllocSize, EntryAlign);
56 assert(Allocation && "Unhandled out-of-memory");
57
58
59 char *Buffer = reinterpret_cast<char *>(Allocation) + EntrySize;
60 if (KeyLength > 0)
61 ::memcpy(Buffer, Key.data(), KeyLength);
62 Buffer[KeyLength] = 0;
63 return Allocation;
64}
65
66
67
68
69
70
71template
73public:
75
78 template <typename... InitTy>
81 second(std::forward(initVals)...) {}
83
86
88};
89
90template <>
99
100
101
102
103template
105public:
107
109
113
114
115
116
118 return reinterpret_cast<const char *>(this + 1);
119 }
120
122
123
124
125 template <typename AllocatorTy, typename... InitTy>
127 InitTy &&...initVals) {
131 }
132
133
134
139
140
141
143
146 allocator.Deallocate(static_cast<void *>(this), AllocSize,
148 }
149};
150
151
152
153template <std::size_t Index, typename ValueTy>
155 static_assert(Index < 2);
156 if constexpr (Index == 0)
157 return E.getKey();
158 else
159 return E.getValue();
160}
161
162template <std::size_t Index, typename ValueTy>
164 static_assert(Index < 2);
165 if constexpr (Index == 0)
166 return E.getKey();
167 else
168 return E.getValue();
169}
170
171}
172
173template
174struct std::tuple_size<llvm::StringMapEntry>
175 : std::integral_constant<std::size_t, 2> {};
176
177template <std::size_t Index, typename ValueTy>
178struct std::tuple_element<Index, llvm::StringMapEntry>
179 : std::tuple_element<Index, std::pair<llvm::StringRef, ValueTy>> {};
180
181#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
StringMapEntryBase - Shared base class of StringMapEntry instances.
Definition StringMapEntry.h:28
size_t getKeyLength() const
Definition StringMapEntry.h:34
static void * allocateWithKey(size_t EntrySize, size_t EntryAlign, StringRef Key, AllocatorTy &Allocator)
Helper to tail-allocate Key.
Definition StringMapEntry.h:47
StringMapEntryBase(size_t keyLength)
Definition StringMapEntry.h:32
StringMapEntryStorage(size_t keyLength, EmptyStringSetTag={})
Definition StringMapEntry.h:93
EmptyStringSetTag getValue() const
Definition StringMapEntry.h:97
StringMapEntryStorage(StringMapEntryStorage &entry)=delete
StringMapEntryStorage(size_t keyLength)
Definition StringMapEntry.h:76
ValueTy & getValue()
Definition StringMapEntry.h:85
StringMapEntryStorage(StringMapEntryStorage &e)=delete
StringMapEntryStorage(size_t keyLength, InitTy &&...initVals)
Definition StringMapEntry.h:79
const ValueTy & getValue() const
Definition StringMapEntry.h:84
void setValue(const ValueTy &V)
Definition StringMapEntry.h:87
ValueTy second
Definition StringMapEntry.h:74
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition StringMapEntry.h:104
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
Definition StringMapEntry.h:126
ValueTy ValueType
Definition StringMapEntry.h:108
StringRef getKey() const
Definition StringMapEntry.h:110
StringRef first() const
Definition StringMapEntry.h:121
void Destroy(AllocatorTy &allocator)
Destroy - Destroy this StringMapEntry, releasing memory back to the specified allocator.
Definition StringMapEntry.h:142
static StringMapEntry & GetStringMapEntryFromKeyData(const char *keyData)
GetStringMapEntryFromKeyData - Given key data that is known to be embedded into a StringMapEntry,...
Definition StringMapEntry.h:135
const char * getKeyData() const
getKeyData - Return the start of the string data that is the key for this value.
Definition StringMapEntry.h:117
StringRef - Represent a constant reference to a string, i.e.
constexpr size_t size() const
size - Get the string size.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Implement std::hash so that hash_code can be used in STL containers.
The "value type" of StringSet represented as an empty struct.
Definition StringMapEntry.h:25