[Target] Remove Process::GetCPPLanguageRuntime

Summary:
I want to remove this method because I think that Process should be
language agnostic, or at least, not have knowledge about specific language
runtimes. There is "GetLanguageRuntime()" which should be used instead. If the
caller a CPPLanguageRuntime, they should cast it as needed. Ideally, this
should only happen in plugins that need C++ specific knowledge.

The next step I would like to do is remove "GetObjCLanguageRuntime()" as well.
There are a lot more instances of that function being used, so I wanted to
upload this one first to get the general reception to this idea.

Reviewers: compnerd, davide, JDevlieghere, jingham, clayborg, labath, aprantl

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D62755

llvm-svn: 362544
This commit is contained in:
Alex Langford 2019-06-04 20:14:33 +00:00
parent a03e2b25ab
commit 29975a2a5d
6 changed files with 8 additions and 15 deletions

View File

@ -43,6 +43,11 @@ public:
return lldb::eLanguageTypeC_plus_plus;
}
static CPPLanguageRuntime *GetCPPLanguageRuntime(Process &process) {
return static_cast<CPPLanguageRuntime *>(
process.GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus));
}
virtual bool IsVTableName(const char *name) = 0;
bool GetObjectDescription(Stream &str, ValueObject &object) override;

View File

@ -2184,8 +2184,6 @@ public:
LanguageRuntime *GetLanguageRuntime(lldb::LanguageType language,
bool retry_if_null = true);
CPPLanguageRuntime *GetCPPLanguageRuntime(bool retry_if_null = true);
ObjCLanguageRuntime *GetObjCLanguageRuntime(bool retry_if_null = true);
bool IsPossibleDynamicValue(ValueObject &in_value);

View File

@ -43,7 +43,6 @@ class BreakpointSiteList;
class BroadcastEventSpec;
class Broadcaster;
class BroadcasterManager;
class CPPLanguageRuntime;
class ClangASTContext;
class ClangASTImporter;
class ClangASTMetadata;

View File

@ -67,7 +67,8 @@ bool lldb_private::formatters::LibcxxFunctionSummaryProvider(
if (process == nullptr)
return false;
CPPLanguageRuntime *cpp_runtime = process->GetCPPLanguageRuntime();
CPPLanguageRuntime *cpp_runtime =
CPPLanguageRuntime::GetCPPLanguageRuntime(*process);
if (!cpp_runtime)
return false;

View File

@ -462,7 +462,7 @@ lldb::SearchFilterSP AppleObjCRuntime::CreateExceptionSearchFilter() {
ValueObjectSP AppleObjCRuntime::GetExceptionObjectForThread(
ThreadSP thread_sp) {
auto cpp_runtime = m_process->GetCPPLanguageRuntime();
auto *cpp_runtime = m_process->GetLanguageRuntime(eLanguageTypeC_plus_plus);
if (!cpp_runtime) return ValueObjectSP();
auto cpp_exception = cpp_runtime->GetExceptionObjectForThread(thread_sp);
if (!cpp_exception) return ValueObjectSP();

View File

@ -1598,16 +1598,6 @@ LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language,
return runtime;
}
CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) {
std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntime *runtime =
GetLanguageRuntime(eLanguageTypeC_plus_plus, retry_if_null);
if (!runtime)
return nullptr;
return static_cast<CPPLanguageRuntime *>(runtime);
}
ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntime *runtime =