-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[lldb][DWARFIndex] Adapt DWARFIndex ObjC APIs to IterationAction #151839
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
Open
Michael137
wants to merge
1
commit into
llvm:main
Choose a base branch
from
Michael137:lldb/dwarf-index-iteration-action-get-objc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[lldb][DWARFIndex] Adapt DWARFIndex ObjC APIs to IterationAction #151839
Michael137
wants to merge
1
commit into
llvm:main
from
Michael137:lldb/dwarf-index-iteration-action-get-objc
+50
−38
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesContinuation of #151489 Full diff: https://github.com/llvm/llvm-project/pull/151839.diff 12 Files Affected:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index d2edfe14b2bae..a258e2b021dad 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 converted_cb =
+ DIERefCallback(IterationActionAdaptor(callback), 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;
|
b61aac4
to
5148fc8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continuation of #151489