We have a few checks in LLDB where we compare a single ConstString against a hardcoded list of strings. This patch introduces a
utility function 'oneOf' in ConstString which is makes this check more readable.
For example, before this patch we had to write this:
if (ft == llvm::sys::fs::file_type::directory_file &&
(file_spec.GetFileNameExtension() == g_sdk_suffix ||
file_spec.GetFileNameExtension() == g_kdk_suffix)) {And after this patch we can now write this:
if (ft == llvm::sys::fs::file_type::directory_file &&
file_spec.GetFileNameExtension().oneOf(g_sdk_suffix, g_kdk_suffix)) {
This is a prime example for a StringSwitch, which is how these kinds of things are usually done in llvm.
return StringSwitch<size_t>(name.GetStringRef()).Cases("ptr, "pointer", 0).Cases("del", "deleter", 1).Cases("obj", "object", "$$dereference$$", 2).Default(UINT32_MAX);(+ running clang-format over that)