[Lldb-commits] [PATCH] D149914: [lldb] Refactor ObjCLanguage::MethodName

Alex Langford via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu May 4 15:41:34 PDT 2023


bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, aprantl, mib, jingham, kastiglione.
Herald added a subscriber: arphaman.
Herald added a reviewer: shafik.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The goal of this patch is to make it easier to reason about the state of
ObjCLanguage::MethodName. I do that in several ways:

- Instead of using the constructor directly, you go through a factory method. It returns a std::optional<MethodName> so either you got an ObjCLanguage::MethodName or you didn't. No more checking if it's valid to know if you can use it or not.
- ObjCLanguage::MethodName is now immutable. You cannot change its internals once it is created.
- ObjCLanguage::MethodName::GetFullNameWithoutCategory previously had a parameter that let you get back an empty string if the method had no category. Every caller of this method was enabling this behavior so I dropped the parameter and made it the default behavior.
- No longer store all the various components of the method name as ConstStrings. The relevant `Get` methods now return llvm::StringRefs backed by the MethodName's internal storage. The lifetime of these StringRefs are tied to the MethodName itself, so if you need to persist these you need to create copies.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149914

Files:
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/unittests/Language/ObjC/ObjCLanguageTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149914.519683.patch
Type: text/x-patch
Size: 26792 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230504/1c9bcd0b/attachment-0001.bin>


More information about the lldb-commits mailing list