Skip to content

Commit d276569

Browse files
authored
[lldb][DWARFIndex] Adapt DebugNamesDWARFIndex::ProcessEntry to IterationAction (#152025)
Continuation of #151489
1 parent a911eee commit d276569

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

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

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,17 @@ DWARFDIE DebugNamesDWARFIndex::GetDIE(const DebugNames::Entry &entry) const {
152152
return DWARFDIE();
153153
}
154154

155-
bool DebugNamesDWARFIndex::ProcessEntry(
155+
IterationAction DebugNamesDWARFIndex::ProcessEntry(
156156
const DebugNames::Entry &entry,
157-
llvm::function_ref<bool(DWARFDIE die)> callback) {
157+
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
158158
DWARFDIE die = GetDIE(entry);
159159
if (!die)
160-
return true;
160+
return IterationAction::Continue;
161161
// Clang used to erroneously emit index entries for declaration DIEs in case
162162
// when the definition is in a type unit (llvm.org/pr77696).
163163
if (die.IsStructUnionOrClass() &&
164164
die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0))
165-
return true;
165+
return IterationAction::Continue;
166166
return callback(die);
167167
}
168168

@@ -185,7 +185,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
185185
if (entry.tag() != DW_TAG_variable)
186186
continue;
187187

188-
if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
188+
if (ProcessEntry(entry, callback) == IterationAction::Stop)
189189
return;
190190
}
191191

@@ -207,7 +207,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
207207
if (entry_or->tag() != DW_TAG_variable)
208208
continue;
209209

210-
if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
210+
if (ProcessEntry(*entry_or, callback) == IterationAction::Stop)
211211
return;
212212
}
213213
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
@@ -243,7 +243,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
243243
continue;
244244

245245
found_entry_for_cu = true;
246-
if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
246+
if (ProcessEntry(*entry_or, callback) == IterationAction::Stop)
247247
return;
248248
}
249249
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
@@ -358,16 +358,15 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType(
358358

359359
if (!parent_chain) {
360360
// Fallback: use the base class implementation.
361-
if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
362-
return GetFullyQualifiedTypeImpl(context, die,
363-
callback);
364-
})))
361+
if (ProcessEntry(entry, [&](DWARFDIE die) {
362+
return GetFullyQualifiedTypeImpl(context, die, callback);
363+
}) == IterationAction::Stop)
365364
return;
366365
continue;
367366
}
368367

369368
if (SameParentChain(parent_names, *parent_chain)) {
370-
if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
369+
if (ProcessEntry(entry, callback) == IterationAction::Stop)
371370
return;
372371
}
373372
}
@@ -462,7 +461,7 @@ void DebugNamesDWARFIndex::GetTypes(
462461
for (const DebugNames::Entry &entry :
463462
m_debug_names_up->equal_range(name.GetStringRef())) {
464463
if (isType(entry.tag())) {
465-
if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
464+
if (ProcessEntry(entry, callback) == IterationAction::Stop)
466465
return;
467466
}
468467
}
@@ -476,7 +475,7 @@ void DebugNamesDWARFIndex::GetTypes(
476475
auto name = context[0].name;
477476
for (const DebugNames::Entry &entry : m_debug_names_up->equal_range(name)) {
478477
if (entry.tag() == context[0].tag) {
479-
if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
478+
if (ProcessEntry(entry, callback) == IterationAction::Stop)
480479
return;
481480
}
482481
}
@@ -492,7 +491,7 @@ void DebugNamesDWARFIndex::GetNamespaces(
492491
llvm::dwarf::Tag entry_tag = entry.tag();
493492
if (entry_tag == DW_TAG_namespace ||
494493
entry_tag == DW_TAG_imported_declaration) {
495-
if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
494+
if (ProcessEntry(entry, callback) == IterationAction::Stop)
496495
return;
497496
}
498497
}
@@ -549,21 +548,20 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
549548
getParentChain(entry);
550549
if (!parent_chain) {
551550
// Fallback: use the base class implementation.
552-
if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
553-
return ProcessTypeDIEMatchQuery(query, die, callback);
554-
})))
551+
if (ProcessEntry(entry, [&](DWARFDIE die) {
552+
return ProcessTypeDIEMatchQuery(query, die, callback);
553+
}) == IterationAction::Stop)
555554
return;
556555
continue;
557556
}
558557

559558
if (WithinParentChain(parent_contexts, *parent_chain)) {
560-
if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
561-
// After .debug_names filtering still sending to base
562-
// class for further filtering before calling the
563-
// callback.
564-
return ProcessTypeDIEMatchQuery(query, die, callback);
565-
})))
566-
// If the callback returns false, we're done.
559+
if (ProcessEntry(entry, [&](DWARFDIE die) {
560+
// After .debug_names filtering still sending to base
561+
// class for further filtering before calling the
562+
// callback.
563+
return ProcessTypeDIEMatchQuery(query, die, callback);
564+
}) == IterationAction::Stop)
567565
return;
568566
}
569567
}
@@ -588,23 +586,22 @@ void DebugNamesDWARFIndex::GetNamespacesWithParents(
588586
getParentChain(entry);
589587
if (!parent_chain) {
590588
// Fallback: use the base class implementation.
591-
if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
592-
return ProcessNamespaceDieMatchParents(
593-
parent_decl_ctx, die, callback);
594-
})))
589+
if (ProcessEntry(entry, [&](DWARFDIE die) {
590+
return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
591+
callback);
592+
}) == IterationAction::Stop)
595593
return;
596594
continue;
597595
}
598596

599597
if (WithinParentChain(parent_named_contexts, *parent_chain)) {
600-
if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
601-
// After .debug_names filtering still sending to
602-
// base class for further filtering before calling
603-
// the callback.
604-
return ProcessNamespaceDieMatchParents(
605-
parent_decl_ctx, die, callback);
606-
})))
607-
// If the callback returns false, we're done.
598+
if (ProcessEntry(entry, [&](DWARFDIE die) {
599+
// After .debug_names filtering still sending to
600+
// base class for further filtering before calling
601+
// the callback.
602+
return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
603+
callback);
604+
}) == IterationAction::Stop)
608605
return;
609606
}
610607
}
@@ -653,7 +650,7 @@ void DebugNamesDWARFIndex::GetFunctions(
653650
if (tag != DW_TAG_subprogram && tag != DW_TAG_inlined_subroutine)
654651
continue;
655652

656-
if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
653+
if (ProcessEntry(*entry_or, callback) == IterationAction::Stop)
657654
return;
658655
}
659656
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,9 @@ class DebugNamesDWARFIndex : public DWARFIndex {
122122
std::optional<DWARFTypeUnit *>
123123
GetForeignTypeUnit(const DebugNames::Entry &entry) const;
124124

125-
bool ProcessEntry(const DebugNames::Entry &entry,
126-
llvm::function_ref<bool(DWARFDIE die)> callback);
125+
IterationAction
126+
ProcessEntry(const DebugNames::Entry &entry,
127+
llvm::function_ref<IterationAction(DWARFDIE die)> callback);
127128

128129
/// Returns true if `parent_entries` have identical names to `parent_names`.
129130
bool SameParentChain(llvm::ArrayRef<llvm::StringRef> parent_names,

0 commit comments

Comments
 (0)