diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h index 52fb0d1f4eae3..2b711db7a5a5c 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h @@ -356,6 +356,10 @@ class ClangASTSource : public clang::ExternalASTSource, /// True if lookup succeeded; false otherwise. ClangASTImporter::DeclOrigin GetDeclOrigin(const clang::Decl *decl); + /// Returns the TypeSystem that uses this ClangASTSource instance as it's + /// ExternalASTSource. + TypeSystemClang *GetTypeSystem() const { return m_clang_ast_context; } + protected: bool FindObjCMethodDeclsWithOrigin( unsigned int current_id, NameSearchContext &context, diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 0a0314dd4b753..bcf13e5c877c2 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -283,17 +283,13 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) { clang::QualType element_qual_type = pointer_pointertype->getPointeeType(); m_result_type = lldb_private::TypeFromParser( - element_qual_type.getAsOpaquePtr(), - lldb_private::TypeSystemClang::GetASTContext( - &result_decl->getASTContext())); + m_decl_map->GetTypeSystem()->GetType(element_qual_type)); } else if (pointer_objcobjpointertype) { clang::QualType element_qual_type = clang::QualType(pointer_objcobjpointertype->getObjectType(), 0); m_result_type = lldb_private::TypeFromParser( - element_qual_type.getAsOpaquePtr(), - lldb_private::TypeSystemClang::GetASTContext( - &result_decl->getASTContext())); + m_decl_map->GetTypeSystem()->GetType(element_qual_type)); } else { LLDB_LOG(log, "Expected result to have pointer type, but it did not"); @@ -305,9 +301,7 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) { } } else { m_result_type = lldb_private::TypeFromParser( - result_var->getType().getAsOpaquePtr(), - lldb_private::TypeSystemClang::GetASTContext( - &result_decl->getASTContext())); + m_decl_map->GetTypeSystem()->GetType(result_var->getType())); } lldb::TargetSP target_sp(m_execution_unit.GetTarget()); @@ -1094,8 +1088,7 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) { clang::VarDecl *decl = reinterpret_cast(ptr); lldb_private::TypeFromParser result_decl_type( - decl->getType().getAsOpaquePtr(), - lldb_private::TypeSystemClang::GetASTContext(&decl->getASTContext())); + m_decl_map->GetTypeSystem()->GetType(decl->getType())); StringRef decl_name(decl->getName()); lldb_private::ConstString persistent_variable_name(decl_name.data(), @@ -1225,10 +1218,8 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) { if (value_decl == nullptr) return false; - lldb_private::CompilerType compiler_type( - lldb_private::TypeSystemClang::GetASTContext( - &value_decl->getASTContext()), - value_decl->getType().getAsOpaquePtr()); + lldb_private::CompilerType compiler_type = + m_decl_map->GetTypeSystem()->GetType(value_decl->getType()); const Type *value_type = nullptr;