13#ifndef LLVM_ADT_STRINGSWITCH_H
14#define LLVM_ADT_STRINGSWITCH_H
20#include <initializer_list>
46template<
typename T,
typename R = T>
53 std::optional<T> Result;
57 : Str(S), Result() { }
75 if (!Result && Str.ends_with(S)) {
76 Result = std::move(
Value);
82 if (!Result && Str.starts_with(S)) {
83 Result = std::move(
Value);
92 if (CaseImpl(S,
Value))
99 CaseLowerImpl(S,
Value);
104 if (!Result && Str.ends_with_insensitive(S))
105 Result = std::move(
Value);
111 if (!Result && Str.starts_with_insensitive(S))
112 Result = std::move(
Value);
121 if (CaseLowerImpl(S,
Value))
129 if (!Result && Pred(Str))
130 Result = std::move(
Value);
136 return std::move(*Result);
142 const char *Message =
"Fell off the end of a string-switch") {
144 return std::move(*Result);
160 Result = std::move(
Value);
170 if (!Str.equals_insensitive(S))
173 Result = std::move(Value);
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.
StringSwitch & EndsWithLower(StringLiteral S, T Value)
StringSwitch & StartsWithLower(StringLiteral S, T Value)
StringSwitch & CaseLower(StringLiteral S, T Value)
StringSwitch & Case(StringLiteral S, T Value)
void operator=(StringSwitch &&)=delete
void operator=(const StringSwitch &)=delete
R DefaultUnreachable(const char *Message="Fell off the end of a string-switch")
Declare default as unreachable, making sure that all cases were handled.
StringSwitch & Predicate(function_ref< bool(StringRef)> Pred, T Value)
StringSwitch & CasesLower(std::initializer_list< StringLiteral > CaseStrings, T Value)
StringSwitch & StartsWith(StringLiteral S, T Value)
StringSwitch(const StringSwitch &)=delete
StringSwitch & EndsWith(StringLiteral S, T Value)
StringSwitch(StringSwitch &&)=default
StringSwitch & Cases(std::initializer_list< StringLiteral > CaseStrings, T Value)
StringSwitch(StringRef S)
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.