diff options
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser')
3 files changed, 26 insertions, 16 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp index 68eaad33f51..24dc7268976 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( - m_target.GetScratchClangASTContext()->getASTContext(), m_ast_context, + ClangASTContext::GetScratch(m_target)->getASTContext(), m_ast_context, decl); if (!D_scratch) { diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 0fef262b1ab..d05c074991e 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -120,14 +120,17 @@ void ClangASTSource::InstallASTContext(ClangASTContext &clang_ast_context, // Update the scratch AST context's merger to reflect any new sources we // might have come across since the last time an expression was parsed. - auto scratch_ast_context = static_cast<ClangASTContextForExpressions*>( - m_target->GetScratchClangASTContext()); + if (auto *clang_ast_context = ClangASTContext::GetScratch(*m_target)) { - scratch_ast_context->GetMergerUnchecked().AddSources(sources); + auto scratch_ast_context = + static_cast<ClangASTContextForExpressions *>(clang_ast_context); - sources.push_back({*scratch_ast_context->getASTContext(), - *scratch_ast_context->getFileManager(), - scratch_ast_context->GetOriginMap()}); + scratch_ast_context->GetMergerUnchecked().AddSources(sources); + + sources.push_back({*scratch_ast_context->getASTContext(), + *scratch_ast_context->getFileManager(), + scratch_ast_context->GetOriginMap()}); + } } m_merger_up = @@ -145,7 +148,7 @@ ClangASTSource::~ClangASTSource() { // demand by passing false to // Target::GetScratchClangASTContext(create_on_demand). ClangASTContext *scratch_clang_ast_context = - m_target->GetScratchClangASTContext(false); + ClangASTContext::GetScratch(*m_target, false); if (!scratch_clang_ast_context) return; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 7a2dbbd16b2..b16c1815caa 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -108,7 +108,7 @@ bool ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx, m_parser_vars->m_persistent_vars = llvm::cast<ClangPersistentVariables>( target->GetPersistentExpressionStateForLanguage(eLanguageTypeC)); - if (!target->GetScratchClangASTContext()) + if (!ClangASTContext::GetScratch(*target)) return false; } @@ -201,7 +201,7 @@ static clang::QualType ExportAllDeclaredTypes( TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target, ClangASTContext &source, TypeFromParser parser_type) { - assert(&target == m_target->GetScratchClangASTContext()); + assert(&target == ClangASTContext::GetScratch(*m_target)); assert((TypeSystem *)&source == parser_type.GetTypeSystem()); assert(source.getASTContext() == m_ast_context); @@ -215,7 +215,7 @@ TypeFromUser ClangExpressionDeclMap::DeportType(ClangASTContext &target, source.getASTContext()->getSourceManager().getFileID( source.getASTContext()->getTranslationUnitDecl()->getLocation()); auto scratch_ast_context = static_cast<ClangASTContextForExpressions *>( - m_target->GetScratchClangASTContext()); + ClangASTContext::GetScratch(*m_target)); clang::QualType exported_type = ExportAllDeclaredTypes( *m_merger_up.get(), scratch_ast_context->GetMergerUnchecked(), *source.getASTContext(), *source.getFileManager(), @@ -248,8 +248,11 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl, if (target == nullptr) return false; - TypeFromUser user_type = - DeportType(*target->GetScratchClangASTContext(), *ast, parser_type); + auto *clang_ast_context = ClangASTContext::GetScratch(*target); + if (!clang_ast_context) + return false; + + TypeFromUser user_type = DeportType(*clang_ast_context, *ast, parser_type); uint32_t offset = m_parser_vars->m_materializer->AddResultVariable( user_type, is_lvalue, m_keep_result_in_memory, m_result_delegate, err); @@ -284,7 +287,9 @@ bool ClangExpressionDeclMap::AddPersistentVariable(const NamedDecl *decl, if (target == nullptr) return false; - ClangASTContext *context(target->GetScratchClangASTContext()); + ClangASTContext *context = ClangASTContext::GetScratch(*target); + if (!context) + return false; TypeFromUser user_type = DeportType(*context, *ast, parser_type); @@ -777,7 +782,7 @@ void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context, return; ClangASTContext *scratch_clang_ast_context = - target->GetScratchClangASTContext(); + ClangASTContext::GetScratch(*target); if (!scratch_clang_ast_context) return; @@ -1714,7 +1719,9 @@ void ClangExpressionDeclMap::AddOneGenericVariable(NameSearchContext &context, if (target == nullptr) return; - ClangASTContext *scratch_ast_context = target->GetScratchClangASTContext(); + ClangASTContext *scratch_ast_context = ClangASTContext::GetScratch(*target); + if (!scratch_ast_context) + return; TypeFromUser user_type(scratch_ast_context->GetBasicType(eBasicTypeVoid) .GetPointerType() |