Skip to content

Commit 8d9afb8

Browse files
authored
[lldb][DWARFIndex] Adapt DWARFIndex ObjC APIs to IterationAction (#151839)
Continuation of #151489
1 parent a3a8e1c commit 8d9afb8

12 files changed

+50
-38
lines changed

lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,22 @@ void AppleDWARFIndex::GetGlobalVariables(
182182
}
183183

184184
void AppleDWARFIndex::GetObjCMethods(
185-
ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
185+
ConstString class_name,
186+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
186187
if (!m_apple_objc_up)
187188
return;
188-
SearchFor(*m_apple_objc_up, class_name, callback);
189+
SearchFor(*m_apple_objc_up, class_name, IterationActionAdaptor(callback));
189190
}
190191

191192
void AppleDWARFIndex::GetCompleteObjCClass(
192193
ConstString class_name, bool must_be_implementation,
193-
llvm::function_ref<bool(DWARFDIE die)> callback) {
194+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
194195
if (!m_apple_types_up)
195196
return;
196197

197198
llvm::SmallVector<DIERef> decl_dies;
198-
auto converted_cb = DIERefCallback(callback, class_name);
199+
auto adapted_cb = IterationActionAdaptor(callback);
200+
auto converted_cb = DIERefCallback(adapted_cb, class_name);
199201

200202
for (const auto &entry : m_apple_types_up->equal_range(class_name)) {
201203
if (HasImplementationFlag(entry)) {

lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H
1111

1212
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
13+
#include "lldb/lldb-private-enumerations.h"
1314
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
1415

1516
namespace lldb_private::plugin {
@@ -50,11 +51,12 @@ class AppleDWARFIndex : public DWARFIndex {
5051
void GetGlobalVariables(
5152
DWARFUnit &cu,
5253
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
53-
void GetObjCMethods(ConstString class_name,
54-
llvm::function_ref<bool(DWARFDIE die)> callback) override;
54+
void GetObjCMethods(
55+
ConstString class_name,
56+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
5557
void GetCompleteObjCClass(
5658
ConstString class_name, bool must_be_implementation,
57-
llvm::function_ref<bool(DWARFDIE die)> callback) override;
59+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
5860
void GetTypes(ConstString name,
5961
llvm::function_ref<bool(DWARFDIE die)> callback) override;
6062
void GetTypes(const DWARFDeclContext &context,

lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "lldb/Utility/LLDBAssert.h"
3838
#include "lldb/Utility/Log.h"
3939
#include "lldb/Utility/StreamString.h"
40+
#include "lldb/lldb-private-enumerations.h"
4041

4142
#include "clang/AST/CXXInheritance.h"
4243
#include "clang/AST/DeclBase.h"
@@ -2223,7 +2224,7 @@ bool DWARFASTParserClang::CompleteRecordType(const DWARFDIE &die,
22232224
if (class_name) {
22242225
dwarf->GetObjCMethods(class_name, [&](DWARFDIE method_die) {
22252226
method_die.ResolveType();
2226-
return true;
2227+
return IterationAction::Continue;
22272228
});
22282229

22292230
for (DelayedAddObjCClassProperty &property : delayed_properties)

lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ class DWARFIndex {
4444
virtual void GetGlobalVariables(
4545
DWARFUnit &cu,
4646
llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
47-
virtual void
48-
GetObjCMethods(ConstString class_name,
49-
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
50-
virtual void
51-
GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
52-
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
47+
virtual void GetObjCMethods(
48+
ConstString class_name,
49+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
50+
virtual void GetCompleteObjCClass(
51+
ConstString class_name, bool must_be_implementation,
52+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
5353
virtual void GetTypes(ConstString name,
5454
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
5555
virtual void GetTypes(const DWARFDeclContext &context,

lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
257257

258258
void DebugNamesDWARFIndex::GetCompleteObjCClass(
259259
ConstString class_name, bool must_be_implementation,
260-
llvm::function_ref<bool(DWARFDIE die)> callback) {
260+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
261261
// Keep a list of incomplete types as fallback for when we don't find the
262262
// complete type.
263263
std::vector<DWARFDIE> incomplete_types;
@@ -283,7 +283,7 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
283283
}
284284

285285
for (DWARFDIE die : incomplete_types)
286-
if (!callback(die))
286+
if (callback(die) == IterationAction::Stop)
287287
return;
288288

289289
m_fallback.GetCompleteObjCClass(class_name, must_be_implementation, callback);

lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class DebugNamesDWARFIndex : public DWARFIndex {
3636
void GetGlobalVariables(
3737
DWARFUnit &cu,
3838
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
39-
void
40-
GetObjCMethods(ConstString class_name,
41-
llvm::function_ref<bool(DWARFDIE die)> callback) override {}
39+
void GetObjCMethods(
40+
ConstString class_name,
41+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override {}
4242
void GetCompleteObjCClass(
4343
ConstString class_name, bool must_be_implementation,
44-
llvm::function_ref<bool(DWARFDIE die)> callback) override;
44+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
4545

4646
/// Uses DWARF5's IDX_parent fields, when available, to speed up this query.
4747
void GetFullyQualifiedType(

lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,18 +438,20 @@ void ManualDWARFIndex::GetGlobalVariables(
438438
}
439439

440440
void ManualDWARFIndex::GetObjCMethods(
441-
ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
441+
ConstString class_name,
442+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
442443
Index();
443444
m_set.objc_class_selectors.Find(
444-
class_name, DIERefCallback(callback, class_name.GetStringRef()));
445+
class_name, DIERefCallback(IterationActionAdaptor(callback),
446+
class_name.GetStringRef()));
445447
}
446448

447449
void ManualDWARFIndex::GetCompleteObjCClass(
448450
ConstString class_name, bool must_be_implementation,
449-
llvm::function_ref<bool(DWARFDIE die)> callback) {
451+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
450452
Index();
451-
m_set.types.Find(class_name,
452-
DIERefCallback(callback, class_name.GetStringRef()));
453+
m_set.types.Find(class_name, DIERefCallback(IterationActionAdaptor(callback),
454+
class_name.GetStringRef()));
453455
}
454456

455457
void ManualDWARFIndex::GetTypes(

lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@ class ManualDWARFIndex : public DWARFIndex {
4040
void GetGlobalVariables(
4141
DWARFUnit &unit,
4242
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
43-
void GetObjCMethods(ConstString class_name,
44-
llvm::function_ref<bool(DWARFDIE die)> callback) override;
43+
void GetObjCMethods(
44+
ConstString class_name,
45+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
4546
void GetCompleteObjCClass(
4647
ConstString class_name, bool must_be_implementation,
47-
llvm::function_ref<bool(DWARFDIE die)> callback) override;
48+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
4849
void GetTypes(ConstString name,
4950
llvm::function_ref<bool(DWARFDIE die)> callback) override;
5051
void GetTypes(const DWARFDeclContext &context,

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,8 @@ SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu) {
16631663
}
16641664

16651665
void SymbolFileDWARF::GetObjCMethods(
1666-
ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
1666+
ConstString class_name,
1667+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
16671668
m_index->GetObjCMethods(class_name, callback);
16681669
}
16691670

@@ -2993,18 +2994,18 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
29932994
// Don't try and resolve the DIE we are looking for with the DIE
29942995
// itself!
29952996
if (type_die == die || !IsStructOrClassTag(type_die.Tag()))
2996-
return true;
2997+
return IterationAction::Continue;
29972998

29982999
if (must_be_implementation) {
29993000
const bool try_resolving_type = type_die.GetAttributeValueAsUnsigned(
30003001
DW_AT_APPLE_objc_complete_type, 0);
30013002
if (!try_resolving_type)
3002-
return true;
3003+
return IterationAction::Continue;
30033004
}
30043005

30053006
Type *resolved_type = ResolveType(type_die, false, true);
30063007
if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
3007-
return true;
3008+
return IterationAction::Continue;
30083009

30093010
DEBUG_PRINTF(
30103011
"resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64
@@ -3016,7 +3017,7 @@ TypeSP SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE(
30163017
if (die)
30173018
GetDIEToType()[die.GetDIE()] = resolved_type;
30183019
type_sp = resolved_type->shared_from_this();
3019-
return false;
3020+
return IterationAction::Stop;
30203021
});
30213022
return type_sp;
30223023
}

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ class SymbolFileDWARF : public SymbolFileCommon {
220220

221221
CompileUnit *GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu);
222222

223-
virtual void GetObjCMethods(ConstString class_name,
224-
llvm::function_ref<bool(DWARFDIE die)> callback);
223+
virtual void
224+
GetObjCMethods(ConstString class_name,
225+
llvm::function_ref<IterationAction(DWARFDIE die)> callback);
225226

226227
DebugMacrosSP ParseDebugMacros(lldb::offset_t *offset);
227228

0 commit comments

Comments
 (0)