Changeset View
Changeset View
Standalone View
Standalone View
include/llvm/ADT/StringSwitch.h
Show All 9 Lines | |||||
// statement whose cases are string literals. | // statement whose cases are string literals. | ||||
// | // | ||||
//===----------------------------------------------------------------------===/ | //===----------------------------------------------------------------------===/ | ||||
#ifndef LLVM_ADT_STRINGSWITCH_H | #ifndef LLVM_ADT_STRINGSWITCH_H | ||||
#define LLVM_ADT_STRINGSWITCH_H | #define LLVM_ADT_STRINGSWITCH_H | ||||
#include "llvm/ADT/StringRef.h" | #include "llvm/ADT/StringRef.h" | ||||
#include "llvm/Support/Compiler.h" | #include "llvm/Support/Compiler.h" | ||||
#include "llvm/Support/ErrorHandling.h" | |||||
#include <cassert> | #include <cassert> | ||||
#include <cstring> | #include <cstring> | ||||
namespace llvm { | namespace llvm { | ||||
/// \brief A switch()-like statement whose cases are string literals. | /// \brief A switch()-like statement whose cases are string literals. | ||||
/// | /// | ||||
/// The StringSwitch class is a simple form of a switch() statement that | /// The StringSwitch class is a simple form of a switch() statement that | ||||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | public: | ||||
LLVM_ATTRIBUTE_ALWAYS_INLINE | LLVM_ATTRIBUTE_ALWAYS_INLINE | ||||
R Default(const T &Value) const { | R Default(const T &Value) const { | ||||
if (Result) | if (Result) | ||||
return *Result; | return *Result; | ||||
return Value; | return Value; | ||||
} | } | ||||
LLVM_ATTRIBUTE_ALWAYS_INLINE | LLVM_ATTRIBUTE_ALWAYS_INLINE | ||||
R UnreachableDefault(const char *Msg) const { | |||||
if (Result) | |||||
return *Result; | |||||
report_fatal_error(Msg); | |||||
} | |||||
LLVM_ATTRIBUTE_ALWAYS_INLINE | |||||
operator R() const { | operator R() const { | ||||
assert(Result && "Fell off the end of a string-switch"); | assert(Result && "Fell off the end of a string-switch"); | ||||
return *Result; | return *Result; | ||||
} | } | ||||
}; | }; | ||||
} // end namespace llvm | } // end namespace llvm | ||||
#endif // LLVM_ADT_STRINGSWITCH_H | #endif // LLVM_ADT_STRINGSWITCH_H |