diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h --- a/lldb/include/lldb/Symbol/ClangASTContext.h +++ b/lldb/include/lldb/Symbol/ClangASTContext.h @@ -564,6 +564,9 @@ // Accessors + llvm::Optional + GetClassName(const CompilerType &compiler_type) override; + ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type, diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -197,6 +197,9 @@ // Accessors + virtual llvm::Optional + GetClassName(const CompilerType &compiler_type) = 0; + virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0; virtual uint32_t diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -25,7 +25,6 @@ #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Expression/ExpressionVariable.h" #include "lldb/Host/Config.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Declaration.h" @@ -2014,20 +2013,34 @@ } bool ValueObject::GetBaseClassPath(Stream &s) { - if (IsBaseClass()) { - bool parent_had_base_class = - GetParent() && GetParent()->GetBaseClassPath(s); - CompilerType compiler_type = GetCompilerType(); - llvm::Optional cxx_class_name = - ClangASTContext::GetCXXClassName(compiler_type); - if (cxx_class_name) { - if (parent_had_base_class) - s.PutCString("::"); - s.PutCString(cxx_class_name.getValue()); - } - return parent_had_base_class || cxx_class_name; + if (!IsBaseClass()) + return false; + + TargetSP target_sp = GetTargetSP(); + if (!target_sp) + return false; + + auto *type_system = GetCompilerType().GetTypeSystem(); + if (!type_system) { + LLDB_LOG( + lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS), + "Unable to get TypeSystem in order to get class name in " + "ValueObject::GetBaseClassPath"); + return false; } - return false; + + llvm::Optional class_name = + type_system->GetClassName(GetCompilerType()); + bool parent_had_base_class = GetParent() && GetParent()->GetBaseClassPath(s); + if (class_name) { + if (parent_had_base_class) + // FIXME: This is still specific to C++. We should implement something + // like `GetClassSeparator` in the Language plugins to figure out what to + // use here. + s.PutCString("::"); + s.PutCString(class_name.getValue()); + } + return parent_had_base_class || class_name; } ValueObject *ValueObject::GetNonBaseClassParent() { diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -3416,6 +3416,13 @@ return ClangASTContextSupportsLanguage(language); } +Optional +ClangASTContext::GetClassName(const CompilerType &compiler_type) { + if (!ClangUtil::IsClangType(compiler_type)) + return llvm::None; + return GetCXXClassName(compiler_type); +} + Optional ClangASTContext::GetCXXClassName(const CompilerType &type) { if (!type)