[Lldb-commits] [lldb] a12ac70 - [lldb][NFC] Move ClangASTContext::m_scratch_ast_source_up to the appropriate class
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Dec 24 07:33:01 PST 2019
Author: Raphael Isemann
Date: 2019-12-24T16:32:40+01:00
New Revision: a12ac7009e99c6f9e72652e34019f07df9970204
URL: https://github.com/llvm/llvm-project/commit/a12ac7009e99c6f9e72652e34019f07df9970204
DIFF: https://github.com/llvm/llvm-project/commit/a12ac7009e99c6f9e72652e34019f07df9970204.diff
LOG: [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.
Added:
Modified:
lldb/include/lldb/Symbol/ClangASTContext.h
lldb/source/Symbol/ClangASTContext.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Symbol/ClangASTContext.h b/lldb/include/lldb/Symbol/ClangASTContext.h
index 59abe19eba1c..c56a4975f53e 100644
--- a/lldb/include/lldb/Symbol/ClangASTContext.h
+++ b/lldb/include/lldb/Symbol/ClangASTContext.h
@@ -943,7 +943,7 @@ class ClangASTContext : public TypeSystem {
clang::DeclarationName
GetDeclarationName(const char *name, const CompilerType &function_clang_type);
-protected:
+private:
const clang::ClassTemplateSpecializationDecl *
GetAsTemplateSpecialization(lldb::opaque_compiler_type_t type);
@@ -962,7 +962,6 @@ class ClangASTContext : public TypeSystem {
std::unique_ptr<clang::Builtin::Context> m_builtins_up;
std::unique_ptr<DWARFASTParserClang> m_dwarf_ast_parser_up;
std::unique_ptr<PDBASTParser> m_pdb_ast_parser_up;
- std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
std::unique_ptr<clang::MangleContext> m_mangle_ctx_up;
uint32_t m_pointer_byte_size = 0;
bool m_ast_owned = false;
@@ -980,7 +979,6 @@ class ClangASTContext : public TypeSystem {
/// ASTContext wasn't created by parsing source code.
clang::Sema *m_sema = nullptr;
-private:
// For ClangASTContext only
ClangASTContext(const ClangASTContext &);
const ClangASTContext &operator=(const ClangASTContext &);
@@ -995,6 +993,8 @@ class ClangASTContextForExpressions : public ClangASTContext {
~ClangASTContextForExpressions() override = default;
+ void Finalize() override;
+
UserExpression *
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
lldb::LanguageType language,
@@ -1016,6 +1016,7 @@ class ClangASTContextForExpressions : public ClangASTContext {
std::unique_ptr<PersistentExpressionState>
m_persistent_variables; // These are the persistent variables associated
// with this process for the expression parser
+ std::unique_ptr<ClangASTSource> m_scratch_ast_source_up;
};
} // namespace lldb_private
diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp
index f98e08848199..937951c0608d 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<ClangASTContextForExpressions> 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<clang::ExternalASTSource> 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<clang::ExternalASTSource> 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,
More information about the lldb-commits
mailing list