diff options
| author | Greg Clayton <gclayton@apple.com> | 2012-10-23 01:50:10 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2012-10-23 01:50:10 +0000 |
| commit | 4a792072ceea00696c9bbce3de74c348cce608b9 (patch) | |
| tree | 24711d5dd558428505777ef2bed986f9309b5f00 /lldb/source | |
| parent | 164bb37c7be710a07879ebe9711da0229aa18021 (diff) | |
| download | bcm5719-llvm-4a792072ceea00696c9bbce3de74c348cce608b9.tar.gz bcm5719-llvm-4a792072ceea00696c9bbce3de74c348cce608b9.zip | |
<rdar://problem/12493007>
Added a new API call to help efficiently determine if a SBValue could have children:
bool
SBValue::MightHaveChildren ();
This is inteneded to be used bui GUI programs that need to show if a SBValue needs a disclosure triangle when displaying a hierarchical type in a tree view without having to complete the type (by calling SBValue::GetNumChildren()) as completing the type is expensive.
llvm-svn: 166460
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/API/SBValue.cpp | 14 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 24 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObjectSyntheticFilter.cpp | 8 |
3 files changed, 46 insertions, 0 deletions
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 318029fdc43..9e80310f045 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -1354,6 +1354,20 @@ SBValue::GetValueAsUnsigned(uint64_t fail_value) return fail_value; } +bool +SBValue::MightHaveChildren () +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + bool has_children = false; + lldb::ValueObjectSP value_sp(GetSP()); + if (value_sp) + has_children = value_sp->MightHaveChildren(); + + if (log) + log->Printf ("SBValue(%p)::HasChildren() => %i", value_sp.get(), has_children); + return has_children; +} + uint32_t SBValue::GetNumChildren () { diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index b5b55c9e24b..41c7dbe94fd 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -597,6 +597,30 @@ ValueObject::GetNumChildren () } return m_children.GetChildrenCount(); } + +bool +ValueObject::MightHaveChildren() +{ + bool has_children; + clang_type_t clang_type = GetClangType(); + if (clang_type) + { + const uint32_t type_info = ClangASTContext::GetTypeInfo (clang_type, + GetClangAST(), + NULL); + if (type_info & (ClangASTContext::eTypeHasChildren | + ClangASTContext::eTypeIsPointer | + ClangASTContext::eTypeIsReference)) + has_children = true; + } + else + { + has_children = GetNumChildren () > 0; + } + return has_children; +} + +// Should only be called by ValueObject::GetNumChildren() void ValueObject::SetNumChildren (uint32_t num_children) { diff --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp index 284515ab592..fe8e90cf181 100644 --- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp +++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp @@ -96,6 +96,14 @@ ValueObjectSynthetic::CalculateNumChildren() return (m_synthetic_children_count = m_synth_filter_ap->CalculateNumChildren()); } +bool +ValueObjectSynthetic::MightHaveChildren() +{ + // TODO: make this more efficient by adding API calls to calculate this efficiently + return GetNumChildren () > 0; +} + + clang::ASTContext * ValueObjectSynthetic::GetClangASTImpl () { |

