Skip to content

Commit 6fde8fe

Browse files
authored
[lldb] Provide default impl for MightHaveChildren (NFC) (llvm#119977)
The vast majority of `SyntheticChildrenFrontEnd` subclasses provide children, and as such implement `MightHaveChildren` with a constant value of `true`. This change makes `true` the default value. With this change, `MightHaveChildren` only needs to be implemented by synthetic providers that can return `false`, which is only 3 subclasses.
1 parent f0e39c4 commit 6fde8fe

32 files changed

+2
-244
lines changed

lldb/include/lldb/DataFormatters/TypeSynthetic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class SyntheticChildrenFrontEnd {
6868
// a false return value from this call if it returns true, then
6969
// CalculateNumChildren() can return any number >= 0 (0 being valid) it
7070
// should if at all possible be more efficient than CalculateNumChildren()
71-
virtual bool MightHaveChildren() = 0;
71+
virtual bool MightHaveChildren() { return true; }
7272

7373
// if this function returns a non-null ValueObject, then the returned
7474
// ValueObject will stand for this ValueObject whenever a "value" request is

lldb/include/lldb/DataFormatters/VectorIterator.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
3030

3131
lldb::ChildCacheState Update() override;
3232

33-
bool MightHaveChildren() override;
34-
3533
size_t GetIndexOfChildWithName(ConstString name) override;
3634

3735
private:

lldb/source/DataFormatters/VectorType.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,6 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
268268
return lldb::ChildCacheState::eRefetch;
269269
}
270270

271-
bool MightHaveChildren() override { return true; }
272-
273271
size_t GetIndexOfChildWithName(ConstString name) override {
274272
const char *item_name = name.GetCString();
275273
uint32_t idx = ExtractIndexFromString(item_name);

lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
144144
return lldb::ChildCacheState::eRefetch;
145145
}
146146

147-
// maybe return false if the block pointer is, say, null
148-
bool MightHaveChildren() override { return true; }
149-
150147
size_t GetIndexOfChildWithName(ConstString name) override {
151148
if (!m_block_struct_type.IsValid())
152149
return UINT32_MAX;

lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
199199
return lldb::ChildCacheState::eRefetch;
200200
}
201201

202-
bool lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::
203-
MightHaveChildren() {
204-
return true;
205-
}
206-
207202
size_t StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName(
208203
ConstString name) {
209204
if (!m_resume_ptr_sp || !m_destroy_ptr_sp)

lldb/source/Plugins/Language/CPlusPlus/Coroutines.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class StdlibCoroutineHandleSyntheticFrontEnd
4040

4141
lldb::ChildCacheState Update() override;
4242

43-
bool MightHaveChildren() override;
44-
4543
size_t GetIndexOfChildWithName(ConstString name) override;
4644

4745
private:

lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd {
3232
return formatters::ExtractIndexFromString(name.GetCString());
3333
}
3434

35-
bool MightHaveChildren() override { return true; }
3635
lldb::ChildCacheState Update() override;
3736
llvm::Expected<uint32_t> CalculateNumChildren() override {
3837
return m_elements.size();

lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class GenericOptionalFrontend : public SyntheticChildrenFrontEnd {
4242
return formatters::ExtractIndexFromString(name.GetCString());
4343
}
4444

45-
bool MightHaveChildren() override { return true; }
4645
llvm::Expected<uint32_t> CalculateNumChildren() override {
4746
return m_has_value ? 1U : 0U;
4847
}

lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,6 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
309309
return lldb::ChildCacheState::eRefetch;
310310
}
311311

312-
bool lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
313-
MightHaveChildren() {
314-
return true;
315-
}
316-
317312
size_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
318313
GetIndexOfChildWithName(ConstString name) {
319314
if (name == "__ptr_")
@@ -412,11 +407,6 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
412407
return lldb::ChildCacheState::eRefetch;
413408
}
414409

415-
bool lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
416-
MightHaveChildren() {
417-
return true;
418-
}
419-
420410
size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
421411
GetIndexOfChildWithName(ConstString name) {
422412
if (name == "pointer")

lldb/source/Plugins/Language/CPlusPlus/LibCxx.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,6 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
102102

103103
lldb::ChildCacheState Update() override;
104104

105-
bool MightHaveChildren() override;
106-
107105
size_t GetIndexOfChildWithName(ConstString name) override;
108106

109107
~LibcxxSharedPtrSyntheticFrontEnd() override;
@@ -122,8 +120,6 @@ class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
122120

123121
lldb::ChildCacheState Update() override;
124122

125-
bool MightHaveChildren() override;
126-
127123
size_t GetIndexOfChildWithName(ConstString name) override;
128124

129125
~LibcxxUniquePtrSyntheticFrontEnd() override;

0 commit comments

Comments
 (0)