[Lldb-commits] [lldb] 0bdb4a3 - [lldb][DWARFIndex][NFC] Change GetNamespace/GetGlobalVariables APIs to use IterationAction (#151668)
via lldb-commits
lldb-commits at lists.llvm.org
Sat Aug 2 07:28:14 PDT 2025
Author: Michael Buch
Date: 2025-08-02T15:28:10+01:00
New Revision: 0bdb4a36465407a529405cc7b84c2d5acb6528c2
URL: https://github.com/llvm/llvm-project/commit/0bdb4a36465407a529405cc7b84c2d5acb6528c2
DIFF: https://github.com/llvm/llvm-project/commit/0bdb4a36465407a529405cc7b84c2d5acb6528c2.diff
LOG: [lldb][DWARFIndex][NFC] Change GetNamespace/GetGlobalVariables APIs to use IterationAction (#151668)
Continuation from https://github.com/llvm/llvm-project/pull/151489
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 9762ead3273da..d2edfe14b2bae 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -136,19 +136,22 @@ void AppleDWARFIndex::SearchFor(const llvm::AppleAcceleratorTable &table,
}
void AppleDWARFIndex::GetGlobalVariables(
- ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString basename,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
if (!m_apple_names_up)
return;
- SearchFor(*m_apple_names_up, basename, callback);
+ SearchFor(*m_apple_names_up, basename, IterationActionAdaptor(callback));
}
void AppleDWARFIndex::GetGlobalVariables(
const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
if (!m_apple_names_up)
return;
- DIERefCallbackImpl converted_cb = DIERefCallback(callback, regex.GetText());
+ auto adataped_cb = IterationActionAdaptor(callback);
+ DIERefCallbackImpl converted_cb =
+ DIERefCallback(adataped_cb, regex.GetText());
for (const auto &entry : m_apple_names_up->entries())
if (std::optional<llvm::StringRef> name = entry.readName();
@@ -158,7 +161,7 @@ void AppleDWARFIndex::GetGlobalVariables(
}
void AppleDWARFIndex::GetGlobalVariables(
- DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ DWARFUnit &cu, llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
if (!m_apple_names_up)
return;
@@ -169,7 +172,8 @@ void AppleDWARFIndex::GetGlobalVariables(
return val.has_value() && *val >= lower_bound && *val < upper_bound;
};
- DIERefCallbackImpl converted_cb = DIERefCallback(callback);
+ auto adataped_cb = IterationActionAdaptor(callback);
+ DIERefCallbackImpl converted_cb = DIERefCallback(adataped_cb);
for (auto entry : m_apple_names_up->entries()) {
if (is_in_range(entry.BaseEntry.getDIESectionOffset()))
if (!converted_cb(entry.BaseEntry))
@@ -267,10 +271,11 @@ void AppleDWARFIndex::GetTypes(
}
void AppleDWARFIndex::GetNamespaces(
- ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
if (!m_apple_namespaces_up)
return;
- SearchFor(*m_apple_namespaces_up, name, callback);
+ SearchFor(*m_apple_namespaces_up, name, IterationActionAdaptor(callback));
}
void AppleDWARFIndex::GetFunctions(
@@ -298,7 +303,7 @@ void AppleDWARFIndex::GetFunctions(
void AppleDWARFIndex::GetFunctions(
const RegularExpression ®ex,
llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
- return GetGlobalVariables(regex, IterationActionAdaptor(callback));
+ return GetGlobalVariables(regex, callback);
}
void AppleDWARFIndex::Dump(Stream &s) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
index c0f0eb646ee98..74da0b2d051f6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
@@ -41,15 +41,15 @@ class AppleDWARFIndex : public DWARFIndex {
void Preload() override {}
- void
- GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void
- GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void
- GetGlobalVariables(DWARFUnit &cu,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetGlobalVariables(
+ ConstString basename,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
+ void GetGlobalVariables(
+ const RegularExpression ®ex,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
+ 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 GetCompleteObjCClass(
@@ -59,8 +59,9 @@ class AppleDWARFIndex : public DWARFIndex {
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetTypes(const DWARFDeclContext &context,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void GetNamespaces(ConstString name,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetNamespaces(
+ ConstString name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetFunctions(
const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index a8065061fdf21..579103046644d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -165,16 +165,16 @@ bool DWARFIndex::ProcessTypeDIEMatchQuery(
void DWARFIndex::GetNamespacesWithParents(
ConstString name, const CompilerDeclContext &parent_decl_ctx,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
GetNamespaces(name, [&](DWARFDIE die) {
return ProcessNamespaceDieMatchParents(parent_decl_ctx, die, callback);
});
}
-bool DWARFIndex::ProcessNamespaceDieMatchParents(
+IterationAction DWARFIndex::ProcessNamespaceDieMatchParents(
const CompilerDeclContext &parent_decl_ctx, DWARFDIE die,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
if (!SymbolFileDWARF::DIEInDeclContext(parent_decl_ctx, die))
- return true;
+ return IterationAction::Continue;
return callback(die);
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index 3578824e720fb..6718024a42e8c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -33,17 +33,17 @@ class DWARFIndex {
/// Finds global variables with the given base name. Any additional filtering
/// (e.g., to only retrieve variables from a given context) should be done by
/// the consumer.
- virtual void
- GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void GetGlobalVariables(
+ ConstString basename,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
- virtual void
- GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ virtual void GetGlobalVariables(
+ const RegularExpression ®ex,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
/// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
- virtual void
- GetGlobalVariables(DWARFUnit &cu,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ 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;
@@ -64,7 +64,7 @@ class DWARFIndex {
llvm::function_ref<bool(DWARFDIE die)> callback);
virtual void
GetNamespaces(ConstString name,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
/// Get type DIEs meeting requires of \a query.
/// in its decl parent chain as subset. A base implementation is provided,
/// Specializations should override this if they are able to provide a faster
@@ -76,10 +76,9 @@ class DWARFIndex {
/// parent_decl_ctx in its decl parent chain. A base implementation
/// is provided. Specializations should override this if they are able to
/// provide a faster implementation.
- virtual void
- GetNamespacesWithParents(ConstString name,
- const CompilerDeclContext &parent_decl_ctx,
- llvm::function_ref<bool(DWARFDIE die)> callback);
+ virtual void GetNamespacesWithParents(
+ ConstString name, const CompilerDeclContext &parent_decl_ctx,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback);
virtual void
GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
@@ -139,9 +138,9 @@ class DWARFIndex {
bool
ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
llvm::function_ref<bool(DWARFDIE die)> callback);
- bool ProcessNamespaceDieMatchParents(
+ IterationAction ProcessNamespaceDieMatchParents(
const CompilerDeclContext &parent_decl_ctx, DWARFDIE die,
- llvm::function_ref<bool(DWARFDIE die)> callback);
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback);
/// Helper to convert callbacks that return an \c IterationAction
/// to a callback that returns a \c bool, where \c true indicates
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 3ae9fcc70893b..8944005ab356a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -178,13 +178,14 @@ void DebugNamesDWARFIndex::MaybeLogLookupError(llvm::Error error,
}
void DebugNamesDWARFIndex::GetGlobalVariables(
- ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString basename,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(basename.GetStringRef())) {
if (entry.tag() != DW_TAG_variable)
continue;
- if (!ProcessEntry(entry, callback))
+ if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
return;
}
@@ -193,7 +194,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
void DebugNamesDWARFIndex::GetGlobalVariables(
const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
for (const DebugNames::NameIndex &ni: *m_debug_names_up) {
for (DebugNames::NameTableEntry nte: ni) {
Mangled mangled_name(nte.getString());
@@ -206,7 +207,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
if (entry_or->tag() != DW_TAG_variable)
continue;
- if (!ProcessEntry(*entry_or, callback))
+ if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
@@ -217,7 +218,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
}
void DebugNamesDWARFIndex::GetGlobalVariables(
- DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ DWARFUnit &cu, llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
uint64_t cu_offset = cu.GetOffset();
bool found_entry_for_cu = false;
for (const DebugNames::NameIndex &ni : *m_debug_names_up) {
@@ -242,7 +243,7 @@ void DebugNamesDWARFIndex::GetGlobalVariables(
continue;
found_entry_for_cu = true;
- if (!ProcessEntry(*entry_or, callback))
+ if (!ProcessEntry(*entry_or, IterationActionAdaptor(callback)))
return;
}
MaybeLogLookupError(entry_or.takeError(), ni, nte.getString());
@@ -482,13 +483,14 @@ void DebugNamesDWARFIndex::GetTypes(
}
void DebugNamesDWARFIndex::GetNamespaces(
- ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
for (const DebugNames::Entry &entry :
m_debug_names_up->equal_range(name.GetStringRef())) {
llvm::dwarf::Tag entry_tag = entry.tag();
if (entry_tag == DW_TAG_namespace ||
entry_tag == DW_TAG_imported_declaration) {
- if (!ProcessEntry(entry, callback))
+ if (!ProcessEntry(entry, IterationActionAdaptor(callback)))
return;
}
}
@@ -566,7 +568,7 @@ void DebugNamesDWARFIndex::GetTypesWithQuery(
void DebugNamesDWARFIndex::GetNamespacesWithParents(
ConstString name, const CompilerDeclContext &parent_decl_ctx,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
std::vector<lldb_private::CompilerContext> parent_contexts =
parent_decl_ctx.GetCompilerContext();
llvm::SmallVector<CompilerContext> parent_named_contexts;
@@ -582,21 +584,22 @@ void DebugNamesDWARFIndex::GetNamespacesWithParents(
getParentChain(entry);
if (!parent_chain) {
// Fallback: use the base class implementation.
- if (!ProcessEntry(entry, [&](DWARFDIE die) {
- return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
- callback);
- }))
+ if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
+ return ProcessNamespaceDieMatchParents(
+ parent_decl_ctx, die, callback);
+ })))
return;
continue;
}
if (WithinParentChain(parent_named_contexts, *parent_chain)) {
- if (!ProcessEntry(entry, [&](DWARFDIE die) {
- // After .debug_names filtering still sending to base class for
- // further filtering before calling the callback.
- return ProcessNamespaceDieMatchParents(parent_decl_ctx, die,
- callback);
- }))
+ if (!ProcessEntry(entry, IterationActionAdaptor([&](DWARFDIE die) {
+ // After .debug_names filtering still sending to
+ // base class for further filtering before calling
+ // the callback.
+ return ProcessNamespaceDieMatchParents(
+ parent_decl_ctx, die, callback);
+ })))
// If the callback returns false, we're done.
return;
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
index 210591904e419..deee6b7c30516 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h
@@ -13,6 +13,7 @@
#include "Plugins/SymbolFile/DWARF/ManualDWARFIndex.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
#include "lldb/Utility/ConstString.h"
+#include "lldb/lldb-private-enumerations.h"
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
#include <optional>
@@ -26,15 +27,15 @@ class DebugNamesDWARFIndex : public DWARFIndex {
void Preload() override { m_fallback.Preload(); }
- void
- GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void
- GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void
- GetGlobalVariables(DWARFUnit &cu,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetGlobalVariables(
+ ConstString basename,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
+ void GetGlobalVariables(
+ const RegularExpression ®ex,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
+ 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 {}
@@ -50,14 +51,15 @@ class DebugNamesDWARFIndex : public DWARFIndex {
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetTypes(const DWARFDeclContext &context,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void GetNamespaces(ConstString name,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetNamespaces(
+ ConstString name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetTypesWithQuery(TypeQuery &query,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetNamespacesWithParents(
ConstString name, const CompilerDeclContext &parent_decl_ctx,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetFunctions(
const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index f96ac7e8793e4..45179274c8b4f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -414,23 +414,27 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
}
void ManualDWARFIndex::GetGlobalVariables(
- ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString basename,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
Index();
- m_set.globals.Find(basename,
- DIERefCallback(callback, basename.GetStringRef()));
+ m_set.globals.Find(basename, DIERefCallback(IterationActionAdaptor(callback),
+ basename.GetStringRef()));
}
void ManualDWARFIndex::GetGlobalVariables(
const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) {
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
Index();
- m_set.globals.Find(regex, DIERefCallback(callback, regex.GetText()));
+ m_set.globals.Find(
+ regex, DIERefCallback(IterationActionAdaptor(callback), regex.GetText()));
}
void ManualDWARFIndex::GetGlobalVariables(
- DWARFUnit &unit, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ DWARFUnit &unit,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
Index();
- m_set.globals.FindAllEntriesForUnit(unit, DIERefCallback(callback));
+ m_set.globals.FindAllEntriesForUnit(
+ unit, DIERefCallback(IterationActionAdaptor(callback)));
}
void ManualDWARFIndex::GetObjCMethods(
@@ -464,9 +468,11 @@ void ManualDWARFIndex::GetTypes(
}
void ManualDWARFIndex::GetNamespaces(
- ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) {
+ ConstString name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) {
Index();
- m_set.namespaces.Find(name, DIERefCallback(callback, name.GetStringRef()));
+ m_set.namespaces.Find(name, DIERefCallback(IterationActionAdaptor(callback),
+ name.GetStringRef()));
}
void ManualDWARFIndex::GetFunctions(
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index 5685ba456f423..746170cad2985 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -12,6 +12,7 @@
#include "Plugins/SymbolFile/DWARF/DWARFIndex.h"
#include "Plugins/SymbolFile/DWARF/ManualDWARFIndexSet.h"
#include "Plugins/SymbolFile/DWARF/NameToDIE.h"
+#include "lldb/lldb-private-enumerations.h"
#include "llvm/ADT/DenseSet.h"
namespace lldb_private::plugin {
@@ -30,15 +31,15 @@ class ManualDWARFIndex : public DWARFIndex {
void Preload() override { Index(); }
- void
- GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void
- GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void
- GetGlobalVariables(DWARFUnit &unit,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetGlobalVariables(
+ ConstString basename,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
+ void GetGlobalVariables(
+ const RegularExpression ®ex,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
+ 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 GetCompleteObjCClass(
@@ -48,8 +49,9 @@ class ManualDWARFIndex : public DWARFIndex {
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetTypes(const DWARFDeclContext &context,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
- void GetNamespaces(ConstString name,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ void GetNamespaces(
+ ConstString name,
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetFunctions(
const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index a3ba061424cc1..42a66ce75d6d6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2349,11 +2349,11 @@ void SymbolFileDWARF::FindGlobalVariables(
assert(sc.module_sp);
if (die.Tag() != DW_TAG_variable && die.Tag() != DW_TAG_member)
- return true;
+ return IterationAction::Continue;
auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
if (!dwarf_cu)
- return true;
+ return IterationAction::Continue;
sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
if (parent_decl_ctx) {
@@ -2368,7 +2368,7 @@ void SymbolFileDWARF::FindGlobalVariables(
if (!actual_parent_decl_ctx ||
(actual_parent_decl_ctx != parent_decl_ctx &&
!parent_decl_ctx.IsContainedInLookup(actual_parent_decl_ctx)))
- return true;
+ return IterationAction::Continue;
}
}
@@ -2382,7 +2382,10 @@ void SymbolFileDWARF::FindGlobalVariables(
variables.RemoveVariableAtIndex(pruned_idx);
}
- return variables.GetSize() - original_size < max_matches;
+ if (variables.GetSize() - original_size < max_matches)
+ return IterationAction::Continue;
+
+ return IterationAction::Stop;
});
// Return the number of variable that were appended to the list
@@ -2422,12 +2425,15 @@ void SymbolFileDWARF::FindGlobalVariables(const RegularExpression ®ex,
DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
if (!dwarf_cu)
- return true;
+ return IterationAction::Continue;
sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
ParseAndAppendGlobalVariable(sc, die, variables);
- return variables.GetSize() - original_size < max_matches;
+ if (variables.GetSize() - original_size < max_matches)
+ return IterationAction::Continue;
+
+ return IterationAction::Stop;
});
}
@@ -2847,14 +2853,17 @@ SymbolFileDWARF::FindNamespace(ConstString name,
m_index->GetNamespacesWithParents(name, parent_decl_ctx, [&](DWARFDIE die) {
if (!DIEInDeclContext(parent_decl_ctx, die, only_root_namespaces))
- return true; // The containing decl contexts don't match
+ return IterationAction::Continue;
DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU());
if (!dwarf_ast)
- return true;
+ return IterationAction::Continue;
namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
- return !namespace_decl_ctx.IsValid();
+ if (namespace_decl_ctx.IsValid())
+ return IterationAction::Stop;
+
+ return IterationAction::Continue;
});
if (log && namespace_decl_ctx) {
@@ -3295,7 +3304,7 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext &sc) {
variables->AddVariableIfUnique(var_sp);
++vars_added;
}
- return true;
+ return IterationAction::Continue;
});
}
return vars_added;
More information about the lldb-commits
mailing list