[Lldb-commits] [PATCH] D149774: [lldb] Use templates to simplify {Get, Set}PropertyAtIndex (NFC)

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 3 10:51:30 PDT 2023


JDevlieghere created this revision.
JDevlieghere added reviewers: labath, bulbazord, jingham.
Herald added a subscriber: arphaman.
Herald added a project: All.
JDevlieghere requested review of this revision.

Use templates to simplify `{Get,Set}PropertyAtIndex`. It has always bothered me how cumbersome those calls are when adding new properties. After this patch, `SetPropertyAtIndex` infers the type from its arguments and `GetPropertyAtIndex` required a single template argument for the return value. As an added benefit, this enables us to remove a bunch of wrappers from `UserSettingsController` and `OptionValueProperties`.

The end goal is to phase out all the methods with option type names (i.e. `GetPropertyAtIndexAsSInt64`) from those two classes. There's more work to be done to get there but this patch keeps growing and I think it has reached critical mass to be reviewed. The remaining methods can be converted/removed incrementally. Besides that there's a few more things we can do to simplify the call sites even more: we can add overloads for booleans and enums to avoid the `static_cast` and `!= 0` comparisons. I didn't include them in this patch because they are more error prone and therefore increase the risk of regressing something.


https://reviews.llvm.org/D149774

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/UserSettingsController.h
  lldb/include/lldb/Interpreter/OptionValue.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/source/Core/CoreProperties.td
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/ModuleList.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/source/Interpreter/Property.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/Thread.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149774.519162.patch
Type: text/x-patch
Size: 82670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230503/e9c51e4c/attachment-0001.bin>


More information about the lldb-commits mailing list