LLVM: include/llvm/ADT/StringSwitch.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_ADT_STRINGSWITCH_H
14#define LLVM_ADT_STRINGSWITCH_H
15
18#include
19#include
20#include
21
22namespace llvm {
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43template<typename T, typename R = T>
45
47
48
49
50 std::optional Result;
51
52public:
54 : Str(S), Result() { }
55
56
58
59
62
64 : Str(other.Str), Result(std::move(other.Result)) { }
65
67
68
70 if (!Result && Str == S) {
71 Result = std::move(Value);
72 }
73 return *this;
74 }
75
77 if (!Result && Str.ends_with(S)) {
78 Result = std::move(Value);
79 }
80 return *this;
81 }
82
84 if (!Result && Str.starts_with(S)) {
85 Result = std::move(Value);
86 }
87 return *this;
88 }
89
92 }
93
97 }
98
102 }
103
107 }
108
113 }
114
119 }
120
125 }
126
132 }
133
138 return Case(S0, Value).Cases(S1, S2, S3, S4, S5, S6, S7, S8, S9, Value);
139 }
140
141
143 if (!Result && Str.equals_insensitive(S))
144 Result = std::move(Value);
145
146 return *this;
147 }
148
150 if (!Result && Str.ends_with_insensitive(S))
152
153 return *this;
154 }
155
157 if (!Result && Str.starts_with_insensitive(S))
158 Result = std::move(Value);
159
160 return *this;
161 }
162
165 }
166
170 }
171
175 }
176
180 }
181
183 if (Result)
184 return std::move(*Result);
186 }
187
188 [[nodiscard]] operator R() {
189 assert(Result && "Fell off the end of a string-switch");
190 return std::move(*Result);
191 }
192};
193
194}
195
196#endif
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
StringRef - Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, T Value)
StringSwitch & EndsWithLower(StringLiteral S, T Value)
StringSwitch & StartsWithLower(StringLiteral S, T Value)
StringSwitch & CaseLower(StringLiteral S, T Value)
StringSwitch & Case(StringLiteral S, T Value)
StringSwitch & CasesLower(StringLiteral S0, StringLiteral S1, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, T Value)
void operator=(const StringSwitch &)=delete
StringSwitch & CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, T Value)
StringSwitch & StartsWith(StringLiteral S, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, StringLiteral S8, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, T Value)
StringSwitch(const StringSwitch &)=delete
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, T Value)
StringSwitch & EndsWith(StringLiteral S, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, T Value)
StringSwitch(StringSwitch &&other)
void operator=(StringSwitch &&other)=delete
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, T Value)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, T Value)
StringSwitch(StringRef S)
StringSwitch & Cases(StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, StringLiteral S8, StringLiteral S9, T Value)
StringSwitch & CasesLower(StringLiteral S0, StringLiteral S1, StringLiteral S2, T Value)
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.