-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[lldb][DWARFIndex][NFC] Change GetNamespace/GetGlobalVariables APIs to use IterationAction #151668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb][DWARFIndex][NFC] Change GetNamespace/GetGlobalVariables APIs to use IterationAction #151668
Conversation
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesContinuation from #151489 Patch is 22.60 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/151668.diff 9 Files Affected:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 9762ead3273da..8e09ce8650cb0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -136,19 +136,19 @@ 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());
+ DIERefCallbackImpl converted_cb = DIERefCallback(IterationActionAdaptor(callback), regex.GetText());
for (const auto &entry : m_apple_names_up->entries())
if (std::optional<llvm::StringRef> name = entry.readName();
@@ -158,7 +158,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 +169,7 @@ void AppleDWARFIndex::GetGlobalVariables(
return val.has_value() && *val >= lower_bound && *val < upper_bound;
};
- DIERefCallbackImpl converted_cb = DIERefCallback(callback);
+ DIERefCallbackImpl converted_cb = DIERefCallback(IterationActionAdaptor(callback));
for (auto entry : m_apple_names_up->entries()) {
if (is_in_range(entry.BaseEntry.getDIESectionOffset()))
if (!converted_cb(entry.BaseEntry))
@@ -267,10 +267,10 @@ 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 +298,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..1965ba7b59d57 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h
@@ -43,13 +43,13 @@ class AppleDWARFIndex : public DWARFIndex {
void
GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetGlobalVariables(DWARFUnit &cu,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetObjCMethods(ConstString class_name,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetCompleteObjCClass(
@@ -60,7 +60,7 @@ class AppleDWARFIndex : public DWARFIndex {
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;
+ 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..bef0d42441da6 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -35,15 +35,15 @@ class DWARFIndex {
/// the consumer.
virtual void
GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) = 0;
virtual void
GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
+ 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;
+ 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
@@ -79,7 +79,7 @@ class DWARFIndex {
virtual void
GetNamespacesWithParents(ConstString name,
const CompilerDeclContext &parent_decl_ctx,
- llvm::function_ref<bool(DWARFDIE die)> callback);
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback);
virtual void
GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
const CompilerDeclContext &parent_decl_ctx,
@@ -139,9 +139,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..b998a21150883 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -178,13 +178,13 @@ 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 +193,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 +206,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 +217,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 +242,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 +482,13 @@ 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 +566,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 +582,21 @@ void DebugNamesDWARFIndex::GetNamespacesWithParents(
getParentChain(entry);
if (!parent_chain) {
// Fallback: use the base class implementation.
- if (!ProcessEntry(entry, [&](DWARFDIE die) {
+ 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) {
+ 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..ebf23cbab4253 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>
@@ -28,13 +29,13 @@ class DebugNamesDWARFIndex : public DWARFIndex {
void
GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetGlobalVariables(DWARFUnit &cu,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetObjCMethods(ConstString class_name,
llvm::function_ref<bool(DWARFDIE die)> callback) override {}
@@ -51,13 +52,13 @@ class DebugNamesDWARFIndex : public DWARFIndex {
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;
+ 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..542dec110bd75 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -414,23 +414,23 @@ 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()));
+ 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 +464,9 @@ 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..d58f49f0001df 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 {
@@ -32,13 +33,13 @@ class ManualDWARFIndex : public DWARFIndex {
void
GetGlobalVariables(ConstString basename,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetGlobalVariables(const RegularExpression ®ex,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void
GetGlobalVariables(DWARFUnit &unit,
- llvm::function_ref<bool(DWARFDIE die)> callback) override;
+ llvm::function_ref<IterationAction(DWARFDIE die)> callback) override;
void GetObjCMethods(ConstString class_name,
llvm::function_ref<bool(DWARFDIE die)> callback) override;
void GetCompleteObjCClass(
@@ -49,7 +50,7 @@ class ManualDWARFIndex : public DWARFIndex {
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;
+ 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 Iterat...
[truncated]
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/22006 Here is the relevant piece of the build log for the reference
|
…o use IterationAction (llvm#151668) Continuation from llvm#151489
Continuation from #151489