[Lldb-commits] [PATCH] D61231: Add 'oneOf' utility function for comparing a ConstString against a set of strings

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Apr 27 11:51:22 PDT 2019


teemperor created this revision.
teemperor added a reviewer: JDevlieghere.
Herald added subscribers: lldb-commits, MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLDB.

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)) {


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D61231

Files:
  lldb/include/lldb/Utility/ConstString.h
  lldb/source/Core/Debugger.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp
  lldb/source/Plugins/Language/ObjC/CF.cpp
  lldb/source/Plugins/Language/ObjC/Cocoa.cpp
  lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/unittests/Utility/ConstStringTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61231.196984.patch
Type: text/x-patch
Size: 11112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190427/b5fa1d12/attachment-0001.bin>


More information about the lldb-commits mailing list