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 @@ -601,8 +601,7 @@ bool SupportsLanguage(lldb::LanguageType language) override; - static bool GetCXXClassName(const CompilerType &type, - std::string &class_name); + static std::string GetCXXClassName(const CompilerType &type); // Type Completion 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 @@ -2023,15 +2023,14 @@ bool parent_had_base_class = GetParent() && GetParent()->GetBaseClassPath(s); CompilerType compiler_type = GetCompilerType(); - std::string cxx_class_name; - bool this_had_base_class = - ClangASTContext::GetCXXClassName(compiler_type, cxx_class_name); - if (this_had_base_class) { + std::string cxx_class_name = + ClangASTContext::GetCXXClassName(compiler_type); + if (!cxx_class_name.empty()) { if (parent_had_base_class) s.PutCString("::"); s.PutCString(cxx_class_name); } - return parent_had_base_class || this_had_base_class; + return parent_had_base_class || !cxx_class_name.empty(); } return false; } 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,20 +3850,19 @@ return ClangASTContextSupportsLanguage(language); } -bool ClangASTContext::GetCXXClassName(const CompilerType &type, - std::string &class_name) { - if (type) { - clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type)); - if (!qual_type.isNull()) { - clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); - if (cxx_record_decl) { - class_name.assign(cxx_record_decl->getIdentifier()->getNameStart()); - return true; - } - } - } - class_name.clear(); - return false; +std::string ClangASTContext::GetCXXClassName(const CompilerType &type) { + if (!type) + return std::string(); + + clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type)); + if (qual_type.isNull()) + return std::string(); + + clang::CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl(); + if (!cxx_record_decl) + return std::string(); + + return cxx_record_decl->getIdentifier()->getNameStart(); } bool ClangASTContext::IsCXXClassType(const CompilerType &type) {