diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-12-21 22:40:52 +0100 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-12-21 22:51:35 +0100 |
commit | f9f49d3594bc7584cc5cb96125ca08f2ad97662c (patch) | |
tree | 9055539f626cc2ce798d895434b6092a9123cf3e /lldb/source/Plugins | |
parent | bf03e17c570171c7a52117fe63ace89d58f328d5 (diff) | |
download | bcm5719-llvm-f9f49d3594bc7584cc5cb96125ca08f2ad97662c.tar.gz bcm5719-llvm-f9f49d3594bc7584cc5cb96125ca08f2ad97662c.zip |
[lldb][NFC] Return a reference from ClangASTContext::getASTContext and remove dead nullptr checks
ClangASTContext::getASTContext() currently returns a ptr but we have an assert there since a
while that the ASTContext is not a nullptr. This causes that we still have a lot of code
that is doing nullptr checks on the result of getASTContext() which is all unreachable code.
This patch changes the return value to a reference to make it clear this can't be a nullptr
and deletes all the nullptr checks.
Diffstat (limited to 'lldb/source/Plugins')
10 files changed, 76 insertions, 103 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp index 6d6830c740d..1caac9e11cb 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -453,7 +453,7 @@ void ASTResultSynthesizer::CommitPersistentDecls() { ConstString name_cs(name.str().c_str()); Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl( - ClangASTContext::GetScratch(m_target)->getASTContext(), decl); + &ClangASTContext::GetScratch(m_target)->getASTContext(), decl); if (!D_scratch) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index e044a4d33b4..ff86f9f818b 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -57,7 +57,7 @@ ClangASTSource::ClangASTSource(const lldb::TargetSP &target, } void ClangASTSource::InstallASTContext(ClangASTContext &clang_ast_context) { - m_ast_context = clang_ast_context.getASTContext(); + m_ast_context = &clang_ast_context.getASTContext(); m_clang_ast_context = &clang_ast_context; m_file_manager = &m_ast_context->getSourceManager().getFileManager(); m_ast_importer_sp->InstallMapCompleter(m_ast_context, *this); @@ -80,14 +80,11 @@ ClangASTSource::~ClangASTSource() { if (!scratch_clang_ast_context) return; - clang::ASTContext *scratch_ast_context = + clang::ASTContext &scratch_ast_context = scratch_clang_ast_context->getASTContext(); - if (!scratch_ast_context) - return; - - if (m_ast_context != scratch_ast_context && m_ast_importer_sp) - m_ast_importer_sp->ForgetSource(scratch_ast_context, m_ast_context); + if (m_ast_context != &scratch_ast_context && m_ast_importer_sp) + m_ast_importer_sp->ForgetSource(&scratch_ast_context, m_ast_context); } void ClangASTSource::StartTranslationUnit(ASTConsumer *Consumer) { @@ -1880,10 +1877,10 @@ clang::NamedDecl *NameSearchContext::AddVarDecl(const CompilerType &type) { IdentifierInfo *ii = m_decl_name.getAsIdentifierInfo(); - clang::ASTContext *ast = lldb_ast->getASTContext(); + clang::ASTContext &ast = lldb_ast->getASTContext(); clang::NamedDecl *Decl = VarDecl::Create( - *ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(), + ast, const_cast<DeclContext *>(m_decl_context), SourceLocation(), SourceLocation(), ii, ClangUtil::GetQualType(type), nullptr, SC_Static); m_decls.push_back(Decl); @@ -1909,7 +1906,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type, QualType qual_type(ClangUtil::GetQualType(type)); - clang::ASTContext *ast = lldb_ast->getASTContext(); + clang::ASTContext &ast = lldb_ast->getASTContext(); const bool isInlineSpecified = false; const bool hasWrittenPrototype = true; @@ -1919,7 +1916,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type, if (extern_c) { context = LinkageSpecDecl::Create( - *ast, context, SourceLocation(), SourceLocation(), + ast, context, SourceLocation(), SourceLocation(), clang::LinkageSpecDecl::LanguageIDs::lang_c, false); } @@ -1931,7 +1928,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type, : m_decl_name; clang::FunctionDecl *func_decl = FunctionDecl::Create( - *ast, context, SourceLocation(), SourceLocation(), decl_name, qual_type, + ast, context, SourceLocation(), SourceLocation(), decl_name, qual_type, nullptr, SC_Extern, isInlineSpecified, hasWrittenPrototype, isConstexprSpecified ? CSK_constexpr : CSK_unspecified); @@ -1952,7 +1949,7 @@ clang::NamedDecl *NameSearchContext::AddFunDecl(const CompilerType &type, QualType arg_qual_type(func_proto_type->getParamType(ArgIndex)); parm_var_decls.push_back( - ParmVarDecl::Create(*ast, const_cast<DeclContext *>(context), + ParmVarDecl::Create(ast, const_cast<DeclContext *>(context), SourceLocation(), SourceLocation(), nullptr, arg_qual_type, nullptr, SC_Static, nullptr)); } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 23202766892..e9ba1bffd34 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -179,7 +179,7 @@ TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target, TypeFromParser parser_type) { assert(&target == ClangASTContext::GetScratch(*m_target)); assert((TypeSystem *)&source == parser_type.GetTypeSystem()); - assert(source.getASTContext() == m_ast_context); + assert(&source.getASTContext() == m_ast_context); if (m_ast_importer_sp) { return TypeFromUser(m_ast_importer_sp->DeportType(target, parser_type)); @@ -741,16 +741,7 @@ clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) { if (!target) return nullptr; - ClangASTContext *scratch_clang_ast_context = - ClangASTContext::GetScratch(*target); - - if (!scratch_clang_ast_context) - return nullptr; - - ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext(); - - if (!scratch_ast_context) - return nullptr; + ClangASTContext::GetScratch(*target); return m_parser_vars->m_persistent_vars->GetPersistentDecl(name); } @@ -1528,15 +1519,6 @@ bool ClangExpressionDeclMap::GetVariableValue(VariableSP &var, return false; } - ASTContext *ast = clang_ast->getASTContext(); - - if (!ast) { - if (log) - log->PutCString( - "There is no AST context for the current execution context"); - return false; - } - DWARFExpression &var_location_expr = var->LocationExpression(); Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr(); diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index 3498c9dd23c..64461fc2bc0 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -466,7 +466,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEndBase::NSArrayMSyntheticFrontE if (clang_ast_context) m_id_type = CompilerType( clang_ast_context, - clang_ast_context->getASTContext()->ObjCBuiltinIdTy.getAsOpaquePtr()); + clang_ast_context->getASTContext().ObjCBuiltinIdTy.getAsOpaquePtr()); if (valobj_sp->GetProcessSP()) m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize(); } @@ -614,7 +614,7 @@ lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>:: if (clang_ast_context) m_id_type = CompilerType(clang_ast_context, clang_ast_context->getASTContext() - ->ObjCBuiltinIdTy.getAsOpaquePtr()); + .ObjCBuiltinIdTy.getAsOpaquePtr()); } } } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp index 6acd6a6df6b..aca0b8fddcc 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCDeclVendor.cpp @@ -132,7 +132,7 @@ public: void StartTranslationUnit(clang::ASTConsumer *Consumer) override { clang::TranslationUnitDecl *translation_unit_decl = - m_decl_vendor.m_ast_ctx.getASTContext()->getTranslationUnitDecl(); + m_decl_vendor.m_ast_ctx.getASTContext().getTranslationUnitDecl(); translation_unit_decl->setHasExternalVisibleStorage(); translation_unit_decl->setHasExternalLexicalStorage(); } @@ -153,7 +153,7 @@ AppleObjCDeclVendor::AppleObjCDeclVendor(ObjCLanguageRuntime &runtime) m_external_source = new AppleObjCExternalASTSource(*this); llvm::IntrusiveRefCntPtr<clang::ExternalASTSource> external_source_owning_ptr( m_external_source); - m_ast_ctx.getASTContext()->setExternalSource(external_source_owning_ptr); + m_ast_ctx.getASTContext().setExternalSource(external_source_owning_ptr); } clang::ObjCInterfaceDecl * @@ -163,7 +163,7 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) { if (iter != m_isa_to_interface.end()) return iter->second; - clang::ASTContext *ast_ctx = m_ast_ctx.getASTContext(); + clang::ASTContext &ast_ctx = m_ast_ctx.getASTContext(); ObjCLanguageRuntime::ClassDescriptorSP descriptor = m_runtime.GetClassDescriptorFromISA(isa); @@ -174,10 +174,10 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) { ConstString name(descriptor->GetClassName()); clang::IdentifierInfo &identifier_info = - ast_ctx->Idents.get(name.GetStringRef()); + ast_ctx.Idents.get(name.GetStringRef()); clang::ObjCInterfaceDecl *new_iface_decl = clang::ObjCInterfaceDecl::Create( - *ast_ctx, ast_ctx->getTranslationUnitDecl(), clang::SourceLocation(), + ast_ctx, ast_ctx.getTranslationUnitDecl(), clang::SourceLocation(), &identifier_info, nullptr, nullptr); ClangASTMetadata meta_data; @@ -187,7 +187,7 @@ AppleObjCDeclVendor::GetDeclForISA(ObjCLanguageRuntime::ObjCISA isa) { new_iface_decl->setHasExternalVisibleStorage(); new_iface_decl->setHasExternalLexicalStorage(); - ast_ctx->getTranslationUnitDecl()->addDecl(new_iface_decl); + ast_ctx.getTranslationUnitDecl()->addDecl(new_iface_decl); m_isa_to_interface[isa] = new_iface_decl; @@ -443,9 +443,9 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { return; FinishDecl(superclass_decl); - clang::ASTContext *context = m_ast_ctx.getASTContext(); - interface_decl->setSuperClass(context->getTrivialTypeSourceInfo( - context->getObjCInterfaceType(superclass_decl))); + clang::ASTContext &context = m_ast_ctx.getASTContext(); + interface_decl->setSuperClass(context.getTrivialTypeSourceInfo( + context.getObjCInterfaceType(superclass_decl))); }; auto instance_method_func = @@ -503,8 +503,8 @@ bool AppleObjCDeclVendor::FinishDecl(clang::ObjCInterfaceDecl *interface_decl) { clang::TypeSourceInfo *const type_source_info = nullptr; const bool is_synthesized = false; clang::ObjCIvarDecl *ivar_decl = clang::ObjCIvarDecl::Create( - *m_ast_ctx.getASTContext(), interface_decl, clang::SourceLocation(), - clang::SourceLocation(), &m_ast_ctx.getASTContext()->Idents.get(name), + m_ast_ctx.getASTContext(), interface_decl, clang::SourceLocation(), + clang::SourceLocation(), &m_ast_ctx.getASTContext().Idents.get(name), ClangUtil::GetQualType(ivar_type), type_source_info, // TypeSourceInfo * clang::ObjCIvarDecl::Public, nullptr, is_synthesized); @@ -559,22 +559,22 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, do { // See if the type is already in our ASTContext. - clang::ASTContext *ast_ctx = m_ast_ctx.getASTContext(); + clang::ASTContext &ast_ctx = m_ast_ctx.getASTContext(); clang::IdentifierInfo &identifier_info = - ast_ctx->Idents.get(name.GetStringRef()); + ast_ctx.Idents.get(name.GetStringRef()); clang::DeclarationName decl_name = - ast_ctx->DeclarationNames.getIdentifier(&identifier_info); + ast_ctx.DeclarationNames.getIdentifier(&identifier_info); clang::DeclContext::lookup_result lookup_result = - ast_ctx->getTranslationUnitDecl()->lookup(decl_name); + ast_ctx.getTranslationUnitDecl()->lookup(decl_name); if (!lookup_result.empty()) { if (clang::ObjCInterfaceDecl *result_iface_decl = llvm::dyn_cast<clang::ObjCInterfaceDecl>(lookup_result[0])) { if (log) { clang::QualType result_iface_type = - ast_ctx->getObjCInterfaceType(result_iface_decl); + ast_ctx.getObjCInterfaceType(result_iface_decl); uint64_t isa_value = LLDB_INVALID_ADDRESS; ClangASTMetadata *metadata = @@ -625,8 +625,7 @@ AppleObjCDeclVendor::FindDecls(ConstString name, bool append, } if (log) { - clang::QualType new_iface_type = - ast_ctx->getObjCInterfaceType(iface_decl); + clang::QualType new_iface_type = ast_ctx.getObjCInterfaceType(iface_decl); LLDB_LOG(log, "AOCTV::FT [{0}] Created {1} (isa 0x{2:x})", current_id, new_iface_type.getAsString(), (uint64_t)isa); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp index 87ae4c2c6c4..399bb120d7a 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.cpp @@ -315,10 +315,8 @@ ObjCLanguageRuntime::EncodingToType::RealizeType(const char *name, CompilerType ObjCLanguageRuntime::EncodingToType::RealizeType( ClangASTContext &ast_ctx, const char *name, bool for_expression) { - clang::ASTContext *clang_ast = ast_ctx.getASTContext(); - if (!clang_ast) - return CompilerType(); - return RealizeType(*clang_ast, name, for_expression); + clang::ASTContext &clang_ast = ast_ctx.getASTContext(); + return RealizeType(clang_ast, name, for_expression); } ObjCLanguageRuntime::EncodingToType::~EncodingToType() {} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 136027ee4d5..5a6ce7f926b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1909,7 +1909,7 @@ bool DWARFASTParserClang::ParseTemplateDIE( } } - clang::ASTContext *ast = m_ast.getASTContext(); + clang::ASTContext &ast = m_ast.getASTContext(); if (!clang_type) clang_type = m_ast.GetBasicType(eBasicTypeVoid); @@ -1929,7 +1929,7 @@ bool DWARFASTParserClang::ParseTemplateDIE( return false; llvm::APInt apint(*size, uval64, is_signed); template_param_infos.args.push_back( - clang::TemplateArgument(*ast, llvm::APSInt(apint, !is_signed), + clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed), ClangUtil::GetQualType(clang_type))); } else { template_param_infos.args.push_back( @@ -3570,18 +3570,20 @@ DWARFASTParserClang::ResolveNamespaceDIE(const DWARFDIE &die) { SymbolFileDWARF *dwarf = die.GetDWARF(); if (namespace_name) { dwarf->GetObjectFile()->GetModule()->LogMessage( - log, "ASTContext => %p: 0x%8.8" PRIx64 - ": DW_TAG_namespace with DW_AT_name(\"%s\") => " - "clang::NamespaceDecl *%p (original = %p)", - static_cast<void *>(m_ast.getASTContext()), die.GetID(), + log, + "ASTContext => %p: 0x%8.8" PRIx64 + ": DW_TAG_namespace with DW_AT_name(\"%s\") => " + "clang::NamespaceDecl *%p (original = %p)", + static_cast<void *>(&m_ast.getASTContext()), die.GetID(), namespace_name, static_cast<void *>(namespace_decl), static_cast<void *>(namespace_decl->getOriginalNamespace())); } else { dwarf->GetObjectFile()->GetModule()->LogMessage( - log, "ASTContext => %p: 0x%8.8" PRIx64 - ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p " - "(original = %p)", - static_cast<void *>(m_ast.getASTContext()), die.GetID(), + log, + "ASTContext => %p: 0x%8.8" PRIx64 + ": DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p " + "(original = %p)", + static_cast<void *>(&m_ast.getASTContext()), die.GetID(), static_cast<void *>(namespace_decl), static_cast<void *>(namespace_decl->getOriginalNamespace())); } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index b58550beb04..2b70f4602b8 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -655,7 +655,7 @@ bool PdbAstBuilder::CompleteTagDecl(clang::TagDecl &tag) { lldbassert(IsTagRecord(type_id, m_index.tpi())); - clang::QualType tag_qt = m_clang.getASTContext()->getTypeDeclType(&tag); + clang::QualType tag_qt = m_clang.getASTContext().getTypeDeclType(&tag); ClangASTContext::SetHasExternalStorage(tag_qt.getAsOpaquePtr(), false); TypeIndex tag_ti = type_id.index; @@ -700,7 +700,7 @@ clang::QualType PdbAstBuilder::CreateSimpleType(TypeIndex ti) { if (ti.getSimpleMode() != SimpleTypeMode::Direct) { clang::QualType direct_type = GetOrCreateType(ti.makeDirect()); - return m_clang.getASTContext()->getPointerType(direct_type); + return m_clang.getASTContext().getPointerType(direct_type); } if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated) @@ -725,19 +725,17 @@ clang::QualType PdbAstBuilder::CreatePointerType(const PointerRecord &pointer) { MemberPointerInfo mpi = pointer.getMemberInfo(); clang::QualType class_type = GetOrCreateType(mpi.ContainingType); - return m_clang.getASTContext()->getMemberPointerType( + return m_clang.getASTContext().getMemberPointerType( pointee_type, class_type.getTypePtr()); } clang::QualType pointer_type; if (pointer.getMode() == PointerMode::LValueReference) - pointer_type = - m_clang.getASTContext()->getLValueReferenceType(pointee_type); + pointer_type = m_clang.getASTContext().getLValueReferenceType(pointee_type); else if (pointer.getMode() == PointerMode::RValueReference) - pointer_type = - m_clang.getASTContext()->getRValueReferenceType(pointee_type); + pointer_type = m_clang.getASTContext().getRValueReferenceType(pointee_type); else - pointer_type = m_clang.getASTContext()->getPointerType(pointee_type); + pointer_type = m_clang.getASTContext().getPointerType(pointee_type); if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None) pointer_type.addConst(); diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp index 740b3901686..bbbd3415158 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp @@ -103,9 +103,7 @@ static CompilerType GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast, const PDBSymbolTypeBuiltin &pdb_type, Encoding encoding, uint32_t width) { - auto *ast = clang_ast.getASTContext(); - if (!ast) - return CompilerType(); + clang::ASTContext &ast = clang_ast.getASTContext(); switch (pdb_type.getBuiltinType()) { default: @@ -119,32 +117,32 @@ GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast, case PDB_BuiltinType::Bool: return clang_ast.GetBasicType(eBasicTypeBool); case PDB_BuiltinType::Long: - if (width == ast->getTypeSize(ast->LongTy)) - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->LongTy.getAsOpaquePtr()); - if (width == ast->getTypeSize(ast->LongLongTy)) - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->LongLongTy.getAsOpaquePtr()); + if (width == ast.getTypeSize(ast.LongTy)) + return CompilerType(ClangASTContext::GetASTContext(&ast), + ast.LongTy.getAsOpaquePtr()); + if (width == ast.getTypeSize(ast.LongLongTy)) + return CompilerType(ClangASTContext::GetASTContext(&ast), + ast.LongLongTy.getAsOpaquePtr()); break; case PDB_BuiltinType::ULong: - if (width == ast->getTypeSize(ast->UnsignedLongTy)) - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->UnsignedLongTy.getAsOpaquePtr()); - if (width == ast->getTypeSize(ast->UnsignedLongLongTy)) - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->UnsignedLongLongTy.getAsOpaquePtr()); + if (width == ast.getTypeSize(ast.UnsignedLongTy)) + return CompilerType(ClangASTContext::GetASTContext(&ast), + ast.UnsignedLongTy.getAsOpaquePtr()); + if (width == ast.getTypeSize(ast.UnsignedLongLongTy)) + return CompilerType(ClangASTContext::GetASTContext(&ast), + ast.UnsignedLongLongTy.getAsOpaquePtr()); break; case PDB_BuiltinType::WCharT: - if (width == ast->getTypeSize(ast->WCharTy)) - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->WCharTy.getAsOpaquePtr()); + if (width == ast.getTypeSize(ast.WCharTy)) + return CompilerType(ClangASTContext::GetASTContext(&ast), + ast.WCharTy.getAsOpaquePtr()); break; case PDB_BuiltinType::Char16: - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->Char16Ty.getAsOpaquePtr()); + return CompilerType(ClangASTContext::GetASTContext(&ast), + ast.Char16Ty.getAsOpaquePtr()); case PDB_BuiltinType::Char32: - return CompilerType(ClangASTContext::GetASTContext(ast), - ast->Char32Ty.getAsOpaquePtr()); + return CompilerType(ClangASTContext::GetASTContext(&ast), + ast.Char32Ty.getAsOpaquePtr()); case PDB_BuiltinType::Float: // Note: types `long double` and `double` have same bit size in MSVC and // there is no information in the PDB to distinguish them. So when falling @@ -428,7 +426,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) { m_uid_to_decl[type.getSymIndexId()] = record_decl; auto inheritance_attr = clang::MSInheritanceAttr::CreateImplicit( - *m_ast.getASTContext(), GetMSInheritance(*udt)); + m_ast.getASTContext(), GetMSInheritance(*udt)); record_decl->addAttr(inheritance_attr); ClangASTContext::StartTagDeclarationDefinition(clang_type); @@ -900,7 +898,7 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) { // Check if the current context already contains the symbol with the name. clang::Decl *decl = - GetDeclFromContextByName(*m_ast.getASTContext(), *decl_context, name); + GetDeclFromContextByName(m_ast.getASTContext(), *decl_context, name); if (!decl) { auto type = symbol_file->ResolveTypeUID(data->getTypeId()); if (!type) @@ -1160,7 +1158,7 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type, } CompilerType underlying_type = m_ast.GetEnumerationIntegerType(enum_type.GetOpaqueQualType()); - uint32_t byte_size = m_ast.getASTContext()->getTypeSize( + uint32_t byte_size = m_ast.getASTContext().getTypeSize( ClangUtil::GetQualType(underlying_type)); auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType( enum_type, decl, name.c_str(), raw_value, byte_size * 8); diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 08e3737865a..69a4470c258 100644 --- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -413,8 +413,7 @@ void SystemRuntimeMacOSX::ReadLibdispatchTSDIndexes() { ClangASTContext *ast_ctx = ClangASTContext::GetScratch(m_process->GetTarget()); - if (ast_ctx->getASTContext() && - m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS) { + if (m_dispatch_tsd_indexes_addr != LLDB_INVALID_ADDRESS) { CompilerType uint16 = ast_ctx->GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, 16); CompilerType dispatch_tsd_indexes_s = ast_ctx->CreateRecordType( |