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 @@ -609,6 +609,10 @@ // Accessors + llvm::Optional + GetClassName(const CompilerType &compiler_type, + const lldb::LanguageType lang_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 @@ -217,6 +217,10 @@ // Accessors + virtual llvm::Optional + GetClassName(const CompilerType &compiler_type, + const lldb::LanguageType lang_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/TypeValidator.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" #include "lldb/Expression/ExpressionVariable.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Declaration.h" @@ -2019,20 +2018,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; + + // TODO: Don't make this specific to C++. + auto type_system_or_err = + target_sp->GetScratchTypeSystemForLanguage(eLanguageTypeC_plus_plus); + if (!type_system_or_err) { + LLDB_LOG_ERROR( + lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS), + type_system_or_err.takeError(), + "Unable to get TypeSystem in order to get class name in " + "ValueObject::GetBaseClassPath"); + return false; } - return false; + + llvm::Optional class_name = type_system_or_err->GetClassName( + GetCompilerType(), eLanguageTypeC_plus_plus); + bool parent_had_base_class = GetParent() && GetParent()->GetBaseClassPath(s); + if (class_name) { + if (parent_had_base_class) + 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 @@ -3850,6 +3850,15 @@ return ClangASTContextSupportsLanguage(language); } +Optional +ClangASTContext::GetClassName(const CompilerType &compiler_type, + const lldb::LanguageType lang_type) { + // TODO: Support more than C++, if needed. + if (lang_type != eLanguageTypeC_plus_plus) + return llvm::None; + return GetCXXClassName(compiler_type); +} + Optional ClangASTContext::GetCXXClassName(const CompilerType &type) { if (!type)