[all-commits] [llvm/llvm-project] 915256: [lldb] Refactor ObjCLanguage::MethodName

Alex via All-commits all-commits at lists.llvm.org
Thu May 18 14:50:26 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 915256388f865a1a42808f168fc388fccff14eda
      https://github.com/llvm/llvm-project/commit/915256388f865a1a42808f168fc388fccff14eda
  Author: Alex Langford <alangford at apple.com>
  Date:   2023-05-18 (Thu, 18 May 2023)

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

  Log Message:
  -----------
  [lldb] Refactor ObjCLanguage::MethodName

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.

Differential Revision: https://reviews.llvm.org/D149914




More information about the All-commits mailing list