13#ifndef LLVM_ADT_STRINGSWITCH_H
14#define LLVM_ADT_STRINGSWITCH_H
42template<
typename T,
typename R = T>
49 std::optional<T> Result;
53 : Str(S), Result() { }
63 : Str(other.Str), Result(
std::
move(other.Result)) { }
74 if (!Result && Str.ends_with(S)) {
75 Result = std::move(
Value);
81 if (!Result && Str.starts_with(S)) {
82 Result = std::move(
Value);
88 return CasesImpl(
Value, S0,
S1);
93 return CasesImpl(
Value, S0,
S1, S2);
98 return CasesImpl(
Value, S0,
S1, S2, S3);
103 return CasesImpl(
Value, S0,
S1, S2, S3, S4);
109 return CasesImpl(
Value, S0,
S1, S2, S3, S4, S5);
115 return CasesImpl(
Value, S0,
S1, S2, S3, S4, S5, S6);
121 return CasesImpl(
Value, S0,
S1, S2, S3, S4, S5, S6, S7);
128 return CasesImpl(
Value, S0,
S1, S2, S3, S4, S5, S6, S7,
S8);
135 return CasesImpl(
Value, S0,
S1, S2, S3, S4, S5, S6, S7,
S8, S9);
140 CaseLowerImpl(
Value, S);
145 if (!Result && Str.ends_with_insensitive(S))
152 if (!Result && Str.starts_with_insensitive(S))
153 Result = std::move(
Value);
159 return CasesLowerImpl(
Value, S0,
S1);
164 return CasesLowerImpl(
Value, S0,
S1, S2);
169 return CasesLowerImpl(
Value, S0,
S1, S2, S3);
174 return CasesLowerImpl(
Value, S0,
S1, S2, S3, S4);
179 return std::move(*Result);
183 [[nodiscard]]
operator R() {
184 assert(Result &&
"Fell off the end of a string-switch");
185 return std::move(*Result);
191 if (!Result && Str == S) {
192 Result = std::move(
Value);
201 if (!Result && Str.equals_insensitive(S)) {
202 Result = std::move(Value);
210 (... || CaseImpl(Value,
Cases));
214 template <
typename...
Args>
217 (... || CaseLowerImpl(Value,
Cases));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
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.