[Lldb-commits] [lldb] [lldb][DWARFIndex] Adapt DWARFIndex ObjC APIs to IterationAction (PR #151839)
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Sat Aug 2 15:49:47 PDT 2025
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/151839
>From 5148fc839b2b41b8586533cc4ea7d34b2ec6bf9a Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 31 Jul 2025 14:50:59 +0100
Subject: [PATCH] [lldb][DWARFIndex] Adapt DWARFIndex ObjC APIs to
IterationAction
Continuation of https://github.com/llvm/llvm-project/pull/151489
---
.../Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp | 10 ++++++----
.../Plugins/SymbolFile/DWARF/AppleDWARFIndex.h | 8 +++++---
.../Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp | 3 ++-
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h | 12 ++++++------
.../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 4 ++--
.../Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h | 8 ++++----
.../Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp | 12 +++++++-----
.../Plugins/SymbolFile/DWARF/ManualDWARFIndex.h | 7 ++++---
.../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 11 ++++++-----
.../Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 5 +++--
.../Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 2 +-
.../Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h | 6 ++++--
12 files changed, 50 insertions(+), 38 deletions(-)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index d2edfe14b2bae..b5c4667332f24 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -182,20 +182,22 @@ void AppleDWARFIndex::GetGlobalVariables(
}
void AppleDWARFIndex::GetObjCMethods(
- ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
if (!m_apple_objc_up)
return;
- SearchFor(*m_apple_objc_up, class_name, callback);
+ SearchFor(*m_apple_objc_up, class_name, IterationActionAdaptor(callback));
}
void AppleDWARFIndex::GetCompleteObjCClass(
ConstString class_name, bool must_be_implementation,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
if (!m_apple_types_up)
return;
llvm::SmallVector<DIERef> decl_dies;
- auto converted_cb = DIERefCallback(callback, class_name);
+ auto adapted_cb = IterationActionAdaptor(callback);
+ auto converted_cb = DIERefCallback(adapted_cb, class_name);
for (const auto &entry : m_apple_types_up->equal_range(class_name)) {
if (HasImplementationFlag(entry)) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
index 74da0b2d051f6..33ac61b510fff 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
@@ -10,6 +10,7 @@
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
+#include "lldb/lldb-private-enumerations.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
namespace lldb_private::plugin {
@@ -50,11 +51,12 @@ class AppleDWARFIndex : public DWARFIndex {
void GetGlobalVariables(
DWARFUnit &cu,
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
- void GetObjCMethods(ConstString class_name,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetObjCMethods(
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetCompleteObjCClass(
ConstString class_name, bool must_be_implementation,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetTypes(ConstString name,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetTypes(const DWARFDeclContext &context,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 781c1c6c5745d..4c6c3054ba179 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -37,6 +37,7 @@
#include "lldb/Utility/LLDBAssert.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
+#include "lldb/lldb-private-enumerations.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclBase.h"
@@ -2223,7 +2224,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
if (class_name) {
dwarf->GetObjCMethods(class_name, [&](DWARFDIE method_die) {
method_die.ResolveType();
- return true;
+ return IterationAction::Continue;
});
for (DelayedAddObjCClassProperty &property : delayed_properties)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index 6718024a42e8c..84749341ea57a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -44,12 +44,12 @@ class DWARFIndex {
virtual void GetGlobalVariables(
DWARFUnit &cu,
llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
- virtual void
- GetObjCMethods(ConstString class_name,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
- virtual void
- GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void GetObjCMethods(
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
+ virtual void GetCompleteObjCClass(
+ ConstString class_name, bool must_be_implementation,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
virtual void GetTypes(ConstString name,
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
virtual void GetTypes(const DWARFDeclContext &context,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 8944005ab356a..2ec876dd552c0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -257,7 +257,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
void DebugNamesDWARFIndex::GetCompleteObjCClass(
ConstString class_name, bool must_be_implementation,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
// Keep a list of incomplete types as fallback for when we don't find the
// complete type.
std::vector<DWARFDIE> incomplete_types;
@@ -283,7 +283,7 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
}
for (DWARFDIE die : incomplete_types)
- if (!callback(die))
+ if (callback(die) == IterationAction::Stop)
return;
m_fallback.GetCompleteObjCClass(class_name, must_be_implementation, callback);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
index deee6b7c30516..0340cb4a16fc7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -36,12 +36,12 @@ class DebugNamesDWARFIndex : public DWARFIndex {
void GetGlobalVariables(
DWARFUnit &cu,
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
- void
- GetObjCMethods(ConstString class_name,
- llvm::function_ref<bool(DWARFDIE die)> callback) override {}
+ void GetObjCMethods(
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override {}
void GetCompleteObjCClass(
ConstString class_name, bool must_be_implementation,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
/// Uses DWARF5's IDX_parent fields, when available, to speed up this query.
void GetFullyQualifiedType(
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 45179274c8b4f..004c9dd35ec08 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -438,18 +438,20 @@ void ManualDWARFIndex::GetGlobalVariables(
}
void ManualDWARFIndex::GetObjCMethods(
- ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
Index();
m_set.objc_class_selectors.Find(
- class_name, DIERefCallback(callback, class_name.GetStringRef()));
+ class_name, DIERefCallback(IterationActionAdaptor(callback),
+ class_name.GetStringRef()));
}
void ManualDWARFIndex::GetCompleteObjCClass(
ConstString class_name, bool must_be_implementation,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
Index();
- m_set.types.Find(class_name,
- DIERefCallback(callback, class_name.GetStringRef()));
+ m_set.types.Find(class_name, DIERefCallback(IterationActionAdaptor(callback),
+ class_name.GetStringRef()));
}
void ManualDWARFIndex::GetTypes(
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index 746170cad2985..6a71068d5aa20 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -40,11 +40,12 @@ class ManualDWARFIndex : public DWARFIndex {
void GetGlobalVariables(
DWARFUnit &unit,
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
- void GetObjCMethods(ConstString class_name,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetObjCMethods(
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetCompleteObjCClass(
ConstString class_name, bool must_be_implementation,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetTypes(ConstString name,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetTypes(const DWARFDeclContext &context,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 42a66ce75d6d6..170631d4ed365 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1663,7 +1663,8 @@ SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu) {
}
void SymbolFileDWARF::GetObjCMethods(
- ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
m_index->GetObjCMethods(class_name, callback);
}
@@ -2993,18 +2994,18 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
// Don't try and resolve the DIE we are looking for with the DIE
// itself!
if (type_die == die || !IsStructOrClassTag(type_die.Tag()))
- return true;
+ return IterationAction::Continue;
if (must_be_implementation) {
const bool try_resolving_type = type_die.GetAttributeValueAsUnsigned(
DW_AT_APPLE_objc_complete_type, 0);
if (!try_resolving_type)
- return true;
+ return IterationAction::Continue;
}
Type *resolved_type = ResolveType(type_die, false, true);
if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
- return true;
+ return IterationAction::Continue;
DEBUG_PRINTF(
"resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64
@@ -3016,7 +3017,7 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
if (die)
GetDIEToType()[die.GetDIE()] = resolved_type;
type_sp = resolved_type->shared_from_this();
- return false;
+ return IterationAction::Stop;
});
return type_sp;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 3ec538da8cf77..5042d919d9d42 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -220,8 +220,9 @@ class SymbolFileDWARF : public SymbolFileCommon {
CompileUnit *GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu);
- virtual void GetObjCMethods(ConstString class_name,
- llvm::function_ref<bool(DWARFDIE die)> callback);
+ virtual void
+ GetObjCMethods(ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback);
DebugMacrosSP ParseDebugMacros(lldb::offset_t *offset);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
index 52de3abca4b77..60d87c3fc2559 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -120,7 +120,7 @@ SymbolFileDWARFDwo::GetForwardDeclCompilerTypeToDIE() {
void SymbolFileDWARFDwo::GetObjCMethods(
lldb_private::ConstString class_name,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
GetBaseSymbolFile().GetObjCMethods(class_name, callback);
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
index 1ab6494f8ef7f..d906e09fe81ab 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -10,6 +10,7 @@
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H
#include "SymbolFileDWARF.h"
+#include "lldb/lldb-private-enumerations.h"
#include <optional>
namespace lldb_private::plugin {
@@ -34,8 +35,9 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {
DWARFCompileUnit *GetDWOCompileUnitForHash(uint64_t hash);
- void GetObjCMethods(ConstString class_name,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetObjCMethods(
+ ConstString class_name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
llvm::Expected<lldb::TypeSystemSP>
GetTypeSystemForLanguage(lldb::LanguageType language) override;
More information about the lldb-commits
mailing list