From a12ac7009e99c6f9e72652e34019f07df9970204 Mon Sep 17 00:00:00 2001 From: Raphael Isemann Date: Tue, 24 Dec 2019 09:31:45 +0100 Subject: [lldb][NFC] Move ClangASTContext::m_scratch_ast_source_up to the appropriate class m_scratch_ast_source_up is only used by ClangASTContextForExpressions so it should also be declared only in that class. Also make all other members of ClangASTContext private and move the initialization code for ClangASTContextForExpressions into the constructor. --- lldb/source/Symbol/ClangASTContext.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lldb/source/Symbol/ClangASTContext.cpp') diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index f98e0884819..937951c0608 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -569,12 +569,6 @@ lldb::TypeSystemSP ClangASTContext::CreateInstance(lldb::LanguageType language, } else if (target && target->IsValid()) { std::shared_ptr ast_sp( new ClangASTContextForExpressions(*target, fixed_arch)); - ast_sp->m_scratch_ast_source_up.reset(new ClangASTSource( - target->shared_from_this(), target->GetClangASTImporter())); - ast_sp->m_scratch_ast_source_up->InstallASTContext(*ast_sp); - llvm::IntrusiveRefCntPtr proxy_ast_source( - ast_sp->m_scratch_ast_source_up->CreateProxy()); - ast_sp->SetExternalSource(proxy_ast_source); return ast_sp; } return lldb::TypeSystemSP(); @@ -630,7 +624,6 @@ void ClangASTContext::Finalize() { m_diagnostics_engine_up.reset(); m_source_manager_up.reset(); m_language_options_up.reset(); - m_scratch_ast_source_up.reset(); } void ClangASTContext::setSema(Sema *s) { @@ -9381,7 +9374,19 @@ ClangASTContext::DeclContextGetClangASTContext(const CompilerDeclContext &dc) { ClangASTContextForExpressions::ClangASTContextForExpressions(Target &target, ArchSpec arch) : ClangASTContext(arch), m_target_wp(target.shared_from_this()), - m_persistent_variables(new ClangPersistentVariables) {} + m_persistent_variables(new ClangPersistentVariables) { + m_scratch_ast_source_up.reset(new ClangASTSource( + target.shared_from_this(), target.GetClangASTImporter())); + m_scratch_ast_source_up->InstallASTContext(*this); + llvm::IntrusiveRefCntPtr proxy_ast_source( + m_scratch_ast_source_up->CreateProxy()); + SetExternalSource(proxy_ast_source); +} + +void ClangASTContextForExpressions::Finalize() { + ClangASTContext::Finalize(); + m_scratch_ast_source_up.reset(); +} UserExpression *ClangASTContextForExpressions::GetUserExpression( llvm::StringRef expr, llvm::StringRef prefix, lldb::LanguageType language, -- cgit v1.2.3