[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; 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; virtual bool IsVTableName(const char *name) = 0;
bool GetObjectDescription(Stream &str, ValueObject &object) override; bool GetObjectDescription(Stream &str, ValueObject &object) override;

View File

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

View File

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

View File

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

View File

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

View File

@ -1598,16 +1598,6 @@ LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language,
return runtime; 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) { ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) {
std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex); std::lock_guard<std::recursive_mutex> guard(m_language_runtimes_mutex);
LanguageRuntime *runtime = LanguageRuntime *runtime =