From 32556cda186de1291f80ecaa29a2edbc3bd1211b Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Tue, 26 Aug 2014 20:54:04 +0000 Subject: Add an API on ValueObject to generate a 'synthetic child' of base class type. Note that in this commit, the term synthetic child is not meant to refer to data formatters, but to the programmatically-generated children stored inside a ValueObject itself llvm-svn: 216483 --- lldb/source/Core/ValueObject.cpp | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'lldb/source') diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 2d13e47923d..a9d00702a02 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -2215,6 +2215,48 @@ ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type return synthetic_child_sp; } +ValueObjectSP +ValueObject::GetSyntheticBase (const ClangASTType& type, bool can_create) +{ + ValueObjectSP synthetic_child_sp; + + char name_str[64]; + snprintf(name_str, sizeof(name_str), "%s", type.GetTypeName().AsCString("")); + ConstString name_const_str(name_str); + + // Check if we have already created a synthetic array member in this + // valid object. If we have we will re-use it. + synthetic_child_sp = GetSyntheticChild (name_const_str); + + if (synthetic_child_sp.get()) + return synthetic_child_sp; + + if (!can_create) + return ValueObjectSP(); + + const uint32_t offset = 0; + const bool is_base_class = true; + + ValueObjectChild *synthetic_child = new ValueObjectChild(*this, + type, + name_const_str, + type.GetByteSize(), + offset, + 0, + 0, + is_base_class, + false, + eAddressTypeInvalid); + if (synthetic_child) + { + AddSyntheticChild(name_const_str, synthetic_child); + synthetic_child_sp = synthetic_child->GetSP(); + synthetic_child_sp->SetName(name_const_str); + } + return synthetic_child_sp; +} + + // your expression path needs to have a leading . or -> // (unless it somehow "looks like" an array, in which case it has // a leading [ symbol). while the [ is meaningful and should be shown -- cgit v1.2.3