[Target] Remove Target::GetScratchClangASTContext
Target doesn't really need to know about ClangASTContext more than any
other TypeSystem. We can create a method ClangASTContext::GetScratch for
anything who needs a ClangASTContext specifically instead of just a
generic TypeSystem.
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 7219c01..3498c9d 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -461,9 +461,8 @@
: SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
m_id_type() {
if (valobj_sp) {
- auto *clang_ast_context = valobj_sp->GetExecutionContextRef()
- .GetTargetSP()
- ->GetScratchClangASTContext();
+ auto *clang_ast_context = ClangASTContext::GetScratch(
+ *valobj_sp->GetExecutionContextRef().GetTargetSP());
if (clang_ast_context)
m_id_type = CompilerType(
clang_ast_context,
@@ -610,9 +609,8 @@
if (valobj_sp) {
CompilerType type = valobj_sp->GetCompilerType();
if (type) {
- auto *clang_ast_context = valobj_sp->GetExecutionContextRef()
- .GetTargetSP()
- ->GetScratchClangASTContext();
+ auto *clang_ast_context = ClangASTContext::GetScratch(
+ *valobj_sp->GetExecutionContextRef().GetTargetSP());
if (clang_ast_context)
m_id_type = CompilerType(clang_ast_context,
clang_ast_context->getASTContext()
@@ -780,11 +778,15 @@
static const ConstString g_zero("[0]");
if (idx == 0) {
- CompilerType id_type(
- m_backend.GetTargetSP()->GetScratchClangASTContext()->GetBasicType(
- lldb::eBasicTypeObjCID));
- return m_backend.GetSyntheticChildAtOffset(
- m_backend.GetProcessSP()->GetAddressByteSize(), id_type, true, g_zero);
+ auto *clang_ast_context =
+ ClangASTContext::GetScratch(*m_backend.GetTargetSP());
+ if (clang_ast_context) {
+ CompilerType id_type(
+ clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID));
+ return m_backend.GetSyntheticChildAtOffset(
+ m_backend.GetProcessSP()->GetAddressByteSize(), id_type, true,
+ g_zero);
+ }
}
return lldb::ValueObjectSP();
}
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 10f66c4..ae00674 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -65,7 +65,7 @@
static CompilerType GetLLDBNSPairType(TargetSP target_sp) {
CompilerType compiler_type;
- ClangASTContext *target_ast_context = target_sp->GetScratchClangASTContext();
+ ClangASTContext *target_ast_context = ClangASTContext::GetScratch(*target_sp);
if (target_ast_context) {
ConstString g___lldb_autogen_nspair("__lldb_autogen_nspair");
diff --git a/lldb/source/Plugins/Language/ObjC/NSError.cpp b/lldb/source/Plugins/Language/ObjC/NSError.cpp
index 97df3be..94a97c8 100644
--- a/lldb/source/Plugins/Language/ObjC/NSError.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSError.cpp
@@ -86,10 +86,10 @@
ValueObjectSP domain_str_sp = ValueObject::CreateValueObjectFromData(
"domain_str", isw.GetAsData(process_sp->GetByteOrder()),
- valobj.GetExecutionContextRef(), process_sp->GetTarget()
- .GetScratchClangASTContext()
- ->GetBasicType(lldb::eBasicTypeVoid)
- .GetPointerType());
+ valobj.GetExecutionContextRef(),
+ ClangASTContext::GetScratch(process_sp->GetTarget())
+ ->GetBasicType(lldb::eBasicTypeVoid)
+ .GetPointerType());
if (!domain_str_sp)
return false;
@@ -156,8 +156,8 @@
m_child_sp = CreateValueObjectFromData(
"_userInfo", isw.GetAsData(process_sp->GetByteOrder()),
m_backend.GetExecutionContextRef(),
- process_sp->GetTarget().GetScratchClangASTContext()->GetBasicType(
- lldb::eBasicTypeObjCID));
+ ClangASTContext::GetScratch(process_sp->GetTarget())
+ ->GetBasicType(lldb::eBasicTypeObjCID));
return false;
}
diff --git a/lldb/source/Plugins/Language/ObjC/NSException.cpp b/lldb/source/Plugins/Language/ObjC/NSException.cpp
index 931794a..6f3c356 100644
--- a/lldb/source/Plugins/Language/ObjC/NSException.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSException.cpp
@@ -69,10 +69,12 @@
InferiorSizedWord userinfo_isw(userinfo, *process_sp);
InferiorSizedWord reserved_isw(reserved, *process_sp);
- CompilerType voidstar = process_sp->GetTarget()
- .GetScratchClangASTContext()
- ->GetBasicType(lldb::eBasicTypeVoid)
- .GetPointerType();
+ auto *clang_ast_context = ClangASTContext::GetScratch(process_sp->GetTarget());
+ if (!clang_ast_context)
+ return false;
+
+ CompilerType voidstar =
+ clang_ast_context->GetBasicType(lldb::eBasicTypeVoid).GetPointerType();
if (name_sp)
*name_sp = ValueObject::CreateValueObjectFromData(
diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
index 9ee6021..587dd13 100644
--- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp
@@ -53,9 +53,8 @@
if (!type_system)
return false;
- ClangASTContext *ast = m_backend.GetExecutionContextRef()
- .GetTargetSP()
- ->GetScratchClangASTContext();
+ ClangASTContext *ast = ClangASTContext::GetScratch(
+ *m_backend.GetExecutionContextRef().GetTargetSP());
if (!ast)
return false;
diff --git a/lldb/source/Plugins/Language/ObjC/NSString.cpp b/lldb/source/Plugins/Language/ObjC/NSString.cpp
index 55e129b..ce54d65 100644
--- a/lldb/source/Plugins/Language/ObjC/NSString.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSString.cpp
@@ -35,7 +35,7 @@
static CompilerType GetNSPathStore2Type(Target &target) {
static ConstString g_type_name("__lldb_autogen_nspathstore2");
- ClangASTContext *ast_ctx = target.GetScratchClangASTContext();
+ ClangASTContext *ast_ctx = ClangASTContext::GetScratch(target);
if (!ast_ctx)
return CompilerType();