diff options
Diffstat (limited to 'lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp')
| -rw-r--r-- | lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp index 68eaad33f51c..77bb9544ea40 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp @@ -388,8 +388,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body, // replace the old statement with the new one // - *last_stmt_ptr = - reinterpret_cast<Stmt *>(result_initialization_stmt_result.get()); + *last_stmt_ptr = static_cast<Stmt *>(result_initialization_stmt_result.get()); return true; } @@ -448,13 +447,20 @@ void ASTResultSynthesizer::RecordPersistentDecl(NamedDecl *D) { } void ASTResultSynthesizer::CommitPersistentDecls() { + auto *state = + m_target.GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC); + if (!state) + return; + + auto *persistent_vars = llvm::cast<ClangPersistentVariables>(state); + ClangASTContext *scratch_ctx = ClangASTContext::GetScratch(m_target); + for (clang::NamedDecl *decl : m_decls) { StringRef name = decl->getName(); ConstString name_cs(name.str().c_str()); Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl( - m_target.GetScratchClangASTContext()->getASTContext(), m_ast_context, - decl); + &scratch_ctx->getASTContext(), decl); if (!D_scratch) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); @@ -472,10 +478,8 @@ void ASTResultSynthesizer::CommitPersistentDecls() { } if (NamedDecl *NamedDecl_scratch = dyn_cast<NamedDecl>(D_scratch)) - llvm::cast<ClangPersistentVariables>( - m_target.GetPersistentExpressionStateForLanguage( - lldb::eLanguageTypeC)) - ->RegisterPersistentDecl(name_cs, NamedDecl_scratch); + persistent_vars->RegisterPersistentDecl(name_cs, NamedDecl_scratch, + scratch_ctx); } } |
