xiaobai updated this revision to Diff 237445. xiaobai added a comment. Rebase
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69820/new/ https://reviews.llvm.org/D69820 Files: lldb/include/lldb/Symbol/ClangASTContext.h lldb/include/lldb/Symbol/TypeSystem.h lldb/source/Core/ValueObject.cpp lldb/source/Symbol/ClangASTContext.cpp
Index: lldb/source/Symbol/ClangASTContext.cpp =================================================================== --- lldb/source/Symbol/ClangASTContext.cpp +++ lldb/source/Symbol/ClangASTContext.cpp @@ -3416,6 +3416,13 @@ return ClangASTContextSupportsLanguage(language); } +Optional<std::string> +ClangASTContext::GetClassName(const CompilerType &compiler_type) { + if (!ClangUtil::IsClangType(compiler_type)) + return llvm::None; + return GetCXXClassName(compiler_type); +} + Optional<std::string> ClangASTContext::GetCXXClassName(const CompilerType &type) { if (!type) Index: lldb/source/Core/ValueObject.cpp =================================================================== --- lldb/source/Core/ValueObject.cpp +++ 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<std::string> 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<std::string> 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() { Index: lldb/include/lldb/Symbol/TypeSystem.h =================================================================== --- lldb/include/lldb/Symbol/TypeSystem.h +++ lldb/include/lldb/Symbol/TypeSystem.h @@ -197,6 +197,9 @@ // Accessors + virtual llvm::Optional<std::string> + GetClassName(const CompilerType &compiler_type) = 0; + virtual ConstString GetTypeName(lldb::opaque_compiler_type_t type) = 0; virtual uint32_t Index: lldb/include/lldb/Symbol/ClangASTContext.h =================================================================== --- lldb/include/lldb/Symbol/ClangASTContext.h +++ lldb/include/lldb/Symbol/ClangASTContext.h @@ -564,6 +564,9 @@ // Accessors + llvm::Optional<std::string> + GetClassName(const CompilerType &compiler_type) override; + ConstString GetTypeName(lldb::opaque_compiler_type_t type) override; uint32_t GetTypeInfo(lldb::opaque_compiler_type_t type,
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits