LLVM  8.0.1
Public Member Functions | List of all members
llvm::StringSwitch< T, R > Class Template Reference

A switch()-like statement whose cases are string literals. More...

#include "llvm/ADT/StringSwitch.h"

Public Member Functions

LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch (StringRef S)
 
 StringSwitch (const StringSwitch &)=delete
 
void operator= (const StringSwitch &)=delete
 
void operator= (StringSwitch &&other)=delete
 
 StringSwitch (StringSwitch &&other)
 
 ~StringSwitch ()=default
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCase (StringLiteral S, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchEndsWith (StringLiteral S, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchStartsWith (StringLiteral S, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, StringLiteral S8, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCases (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, StringLiteral S5, StringLiteral S6, StringLiteral S7, StringLiteral S8, StringLiteral S9, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCaseLower (StringLiteral S, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchEndsWithLower (StringLiteral S, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchStartsWithLower (StringLiteral S, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, StringLiteral S2, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, T Value)
 
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitchCasesLower (StringLiteral S0, StringLiteral S1, StringLiteral S2, StringLiteral S3, StringLiteral S4, T Value)
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINEDefault (T Value)
 
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE operator R ()
 

Detailed Description

template<typename T, typename R = T>
class llvm::StringSwitch< T, R >

A switch()-like statement whose cases are string literals.

The StringSwitch class is a simple form of a switch() statement that determines whether the given string matches one of the given string literals. The template type parameter T is the type of the value that will be returned from the string-switch expression. For example, the following code switches on the name of a color in argv[i]:

Color color = StringSwitch<Color>(argv[i])
.Case("red", Red)
.Case("orange", Orange)
.Case("yellow", Yellow)
.Case("green", Green)
.Case("blue", Blue)
.Case("indigo", Indigo)
.Cases("violet", "purple", Violet)
.Default(UnknownColor);

Definition at line 43 of file StringSwitch.h.

Constructor & Destructor Documentation

◆ StringSwitch() [1/3]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE llvm::StringSwitch< T, R >::StringSwitch ( StringRef  S)
inlineexplicit

Definition at line 53 of file StringSwitch.h.

References llvm::StringSwitch< T, R >::operator=().

◆ StringSwitch() [2/3]

template<typename T , typename R = T>
llvm::StringSwitch< T, R >::StringSwitch ( const StringSwitch< T, R > &  )
delete

◆ StringSwitch() [3/3]

template<typename T , typename R = T>
llvm::StringSwitch< T, R >::StringSwitch ( StringSwitch< T, R > &&  other)
inline

◆ ~StringSwitch()

template<typename T , typename R = T>
llvm::StringSwitch< T, R >::~StringSwitch ( )
default

Member Function Documentation

◆ Case()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Case ( StringLiteral  S,
T  Value 
)
inline

Definition at line 70 of file StringSwitch.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE.

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), llvm::StringSwitch< T, R >::Cases(), checkParametrizedPassName(), llvm::classifyEHPersonality(), llvm::DWARFContext::defaultErrorHandler(), llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernel(), llvm::MipsSEFrameLowering::emitPrologue(), encodeCnt(), llvm::ARM::getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), getARClassRegisterMask(), llvm::DIFile::getChecksumKind(), llvm::DICompileUnit::getEmissionKind(), getEmulation(), llvm::ConstrainedFPIntrinsic::getExceptionBehavior(), llvm::MipsAsmBackend::getFixupKind(), llvm::ARM::getFPUSynonym(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), llvm::sys::getHostNumPhysicalCores(), getIdentifierKind(), llvm::TGLexer::getLoc(), llvm::dwarf::getMacinfo(), getMClassFlagsMask(), getMetadataKeywordKind(), llvm::DICompileUnit::getNameTableKind(), getNextRegister(), getOSTypeFromPlatform(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), getRelaxedOpcode(), llvm::ConstrainedFPIntrinsic::getRoundingMode(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), getSpecialRegForName(), llvm::MipsTargetLowering::getTypeForExtReturn(), llvm::RISCVMCExpr::getVariantKindForName(), llvm::object::WasmObjectFile::getWasmRelocation(), llvm::yaml::ScalarTraits< ELFArchMapper >::input(), isRegOrImmWithInputMods(), llvm::object::MachOObjectFile::isValidArch(), matchSVEPredicateVectorRegName(), mayTailCallThisCC(), MCAttrForString(), parseArch(), parseAttrKind(), parseNamePrefix(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), llvm::SymbolRemappingReader::read(), RefineErrorLoc(), llvm::LPAC::stringToLanaiAluCode(), llvm::RISCVFPRndMode::stringToRoundingMode(), and UpgradeIntrinsicFunction1().

◆ CaseLower()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CaseLower ( StringLiteral  S,
T  Value 
)
inline

◆ Cases() [1/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
T  Value 
)
inline

◆ Cases() [2/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
T  Value 
)
inline

◆ Cases() [3/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
T  Value 
)
inline

◆ Cases() [4/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
T  Value 
)
inline

◆ Cases() [5/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
T  Value 
)
inline

◆ Cases() [6/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
T  Value 
)
inline

◆ Cases() [7/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
T  Value 
)
inline

◆ Cases() [8/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
StringLiteral  S8,
T  Value 
)
inline

◆ Cases() [9/9]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::Cases ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
StringLiteral  S5,
StringLiteral  S6,
StringLiteral  S7,
StringLiteral  S8,
StringLiteral  S9,
T  Value 
)
inline

◆ CasesLower() [1/4]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
T  Value 
)
inline

◆ CasesLower() [2/4]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
T  Value 
)
inline

◆ CasesLower() [3/4]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
T  Value 
)
inline

◆ CasesLower() [4/4]

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::CasesLower ( StringLiteral  S0,
StringLiteral  S1,
StringLiteral  S2,
StringLiteral  S3,
StringLiteral  S4,
T  Value 
)
inline

◆ Default()

template<typename T , typename R = T>
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R llvm::StringSwitch< T, R >::Default ( T  Value)
inline

Definition at line 203 of file StringSwitch.h.

References LLVM_ATTRIBUTE_ALWAYS_INLINE, and LLVM_NODISCARD.

Referenced by llvm::AArch64StringToVectorLayout(), llvm::ARMCondCodeFromString(), checkParametrizedPassName(), llvm::classifyEHPersonality(), llvm::createX86_64AsmBackend(), llvm::DWARFContext::defaultErrorHandler(), llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernel(), llvm::MipsSEFrameLowering::emitPrologue(), encodeCnt(), llvm::ARM::getArchSynonym(), llvm::Triple::getArchTypeForLLVMName(), getARClassRegisterMask(), llvm::DIFile::getChecksumKind(), llvm::DICompileUnit::getEmissionKind(), getEmulation(), llvm::ConstrainedFPIntrinsic::getExceptionBehavior(), llvm::MipsAsmBackend::getFixupKind(), llvm::ARM::getFPUSynonym(), llvm::sys::detail::getHostCPUNameForARM(), llvm::sys::detail::getHostCPUNameForPowerPC(), llvm::sys::getHostNumPhysicalCores(), getHWDivSynonym(), getIdentifierKind(), llvm::TGLexer::getLoc(), llvm::dwarf::getMacinfo(), getMClassFlagsMask(), getMetadataKeywordKind(), llvm::DICompileUnit::getNameTableKind(), getNextRegister(), getOSTypeFromPlatform(), llvm::LanaiTargetLowering::getRegisterByName(), llvm::SparcTargetLowering::getRegisterByName(), llvm::AVRTargetLowering::getRegisterByName(), llvm::HexagonTargetLowering::getRegisterByName(), llvm::SITargetLowering::getRegisterByName(), llvm::MipsTargetLowering::getRegisterByName(), llvm::PPCTargetLowering::getRegisterByName(), llvm::X86TargetLowering::getRegisterByName(), getRelaxedOpcode(), llvm::ConstrainedFPIntrinsic::getRoundingMode(), llvm::pdb::PDBSymbolCompiland::getSourceFileFullPath(), getSpecialRegForName(), llvm::MipsTargetLowering::getTypeForExtReturn(), llvm::RISCVMCExpr::getVariantKindForName(), llvm::object::WasmObjectFile::getWasmRelocation(), llvm::yaml::ScalarTraits< ELFArchMapper >::input(), isRegOrImmWithInputMods(), llvm::object::MachOObjectFile::isValidArch(), LowerVectorINT_TO_FP(), llvm::object::MachOObjectFile::mapDebugSectionName(), llvm::object::COFFObjectFile::mapDebugSectionName(), matchSVEPredicateVectorRegName(), MaybePredicatedInst(), mayTailCallThisCC(), MCAttrForString(), parseArch(), llvm::ARM::parseArchISA(), parseAttrKind(), parseEnvironment(), parseFormat(), parseNamePrefix(), parseOS(), parseSubArch(), llvm::SparcMCExpr::parseVariantKind(), parseVendor(), llvm::SymbolRemappingReader::read(), RefineErrorLoc(), SizeForSuffix(), llvm::LPAC::stringToLanaiAluCode(), llvm::RISCVFPRndMode::stringToRoundingMode(), llvm::LPCC::suffixToLanaiCondCode(), llvm::Triple::Triple(), and UpgradeIntrinsicFunction1().

◆ EndsWith()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::EndsWith ( StringLiteral  S,
T  Value 
)
inline

◆ EndsWithLower()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::EndsWithLower ( StringLiteral  S,
T  Value 
)
inline

◆ operator R()

template<typename T , typename R = T>
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE llvm::StringSwitch< T, R >::operator R ( )
inline

Definition at line 211 of file StringSwitch.h.

References assert().

◆ operator=() [1/2]

template<typename T , typename R = T>
void llvm::StringSwitch< T, R >::operator= ( const StringSwitch< T, R > &  )
delete

◆ operator=() [2/2]

template<typename T , typename R = T>
void llvm::StringSwitch< T, R >::operator= ( StringSwitch< T, R > &&  other)
delete

◆ StartsWith()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::StartsWith ( StringLiteral  S,
T  Value 
)
inline

◆ StartsWithLower()

template<typename T , typename R = T>
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch& llvm::StringSwitch< T, R >::StartsWithLower ( StringLiteral  S,
T  Value 
)
inline

The documentation for this class was generated from the following file: