[Lldb-commits] [lldb] [lldb][NFC] Use unique ptr in AppleObjCRuntime {GetSuperclass, GetMetaclass} (PR #202893)
Felipe de Azevedo Piovezan via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 10 03:13:33 PDT 2026
https://github.com/felipepiovezan updated https://github.com/llvm/llvm-project/pull/202893
>From 6fb540f413f5ea3e5846152ce219c3e78017bd41 Mon Sep 17 00:00:00 2001
From: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: Wed, 10 Jun 2026 11:12:05 +0100
Subject: [PATCH] [lldb][NFC] Use unique ptr in AppleObjCRuntime::GetMetaclass
This method doesn't need to return a shared pointer.
---
.../AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp | 11 ++++++-----
.../AppleObjCRuntime/AppleObjCClassDescriptorV2.h | 6 +++---
.../ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp | 4 ++--
.../ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h | 2 +-
.../LanguageRuntime/ObjC/ObjCLanguageRuntime.h | 2 +-
5 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 1b8992d5e3f5d..f37c33668af9c 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -588,7 +588,7 @@ bool ClassDescriptorV2::Describe(
}
if (class_method_func) {
- AppleObjCRuntime::ClassDescriptorSP metaclass(GetMetaclass());
+ std::unique_ptr<ClassDescriptor> metaclass = GetMetaclass();
// We don't care about the metaclass's superclass, or its class methods.
// Its instance methods are our class methods.
@@ -670,21 +670,22 @@ ObjCLanguageRuntime::ClassDescriptorSP ClassDescriptorV2::GetSuperclass() {
objc_class->m_superclass);
}
-ObjCLanguageRuntime::ClassDescriptorSP ClassDescriptorV2::GetMetaclass() const {
+std::unique_ptr<ObjCLanguageRuntime::ClassDescriptor>
+ClassDescriptorV2::GetMetaclass() const {
lldb_private::Process *process = m_runtime.GetProcess();
if (!process)
- return ObjCLanguageRuntime::ClassDescriptorSP();
+ return nullptr;
auto objc_class = objc_class_t::Read(process, m_objc_class_ptr);
if (!objc_class) {
LLDB_LOG_ERROR(GetLog(LLDBLog::Types), objc_class.takeError(), "{0}");
- return ObjCLanguageRuntime::ClassDescriptorSP();
+ return nullptr;
}
lldb::addr_t candidate_isa = m_runtime.GetPointerISA(objc_class->m_isa);
- return ObjCLanguageRuntime::ClassDescriptorSP(
+ return std::unique_ptr<ClassDescriptor>(
new ClassDescriptorV2(m_runtime, candidate_isa, nullptr));
}
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index e62eedf92c579..ebfdfcbfebe23 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -29,7 +29,7 @@ class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor {
ObjCLanguageRuntime::ClassDescriptorSP GetSuperclass() override;
- ObjCLanguageRuntime::ClassDescriptorSP GetMetaclass() const override;
+ std::unique_ptr<ClassDescriptor> GetMetaclass() const override;
bool IsValid() override {
return true; // any Objective-C v2 runtime class descriptor we vend is valid
@@ -322,8 +322,8 @@ class ClassDescriptorV2Tagged : public ObjCLanguageRuntime::ClassDescriptor {
return ObjCLanguageRuntime::ClassDescriptorSP();
}
- ObjCLanguageRuntime::ClassDescriptorSP GetMetaclass() const override {
- return ObjCLanguageRuntime::ClassDescriptorSP();
+ std::unique_ptr<ClassDescriptor> GetMetaclass() const override {
+ return nullptr;
}
bool IsValid() override { return m_valid; }
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
index ad5d17361e2af..4ddef329b3ed0 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
@@ -259,9 +259,9 @@ AppleObjCRuntimeV1::ClassDescriptorV1::GetSuperclass() {
new AppleObjCRuntimeV1::ClassDescriptorV1(m_parent_isa, process_sp));
}
-AppleObjCRuntime::ClassDescriptorSP
+std::unique_ptr<AppleObjCRuntime::ClassDescriptor>
AppleObjCRuntimeV1::ClassDescriptorV1::GetMetaclass() const {
- return ClassDescriptorSP();
+ return nullptr;
}
bool AppleObjCRuntimeV1::ClassDescriptorV1::Describe(
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
index c51ac24e690b8..9e74a735cbc62 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
@@ -53,7 +53,7 @@ class AppleObjCRuntimeV1 : public AppleObjCRuntime {
ClassDescriptorSP GetSuperclass() override;
- ClassDescriptorSP GetMetaclass() const override;
+ std::unique_ptr<ClassDescriptor> GetMetaclass() const override;
bool IsValid() override { return m_valid; }
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
index fc19da0ac0f98..c5b023459c5a7 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h
@@ -63,7 +63,7 @@ class ObjCLanguageRuntime : public LanguageRuntime {
virtual ClassDescriptorSP GetSuperclass() = 0;
- virtual ClassDescriptorSP GetMetaclass() const = 0;
+ virtual std::unique_ptr<ClassDescriptor> GetMetaclass() const = 0;
// virtual if any implementation has some other version-specific rules but
// for the known v1/v2 this is all that needs to be done
More information about the lldb-commits
mailing list