From 4a792072ceea00696c9bbce3de74c348cce608b9 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 23 Oct 2012 01:50:10 +0000 Subject: 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 --- lldb/source/Core/ValueObject.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lldb/source/Core/ValueObject.cpp') 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) { -- cgit v1.2.3