Skip to content

Commit

Permalink
[Target] Remove Process::GetCPPLanguageRuntime
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bulbazord committed Jun 4, 2019
1 parent a03e2b2 commit 29975a2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
5 changes: 5 additions & 0 deletions lldb/include/lldb/Target/CPPLanguageRuntime.h
Expand Up @@ -43,6 +43,11 @@ class CPPLanguageRuntime : public LanguageRuntime {
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;
Expand Down
2 changes: 0 additions & 2 deletions lldb/include/lldb/Target/Process.h
Expand Up @@ -2184,8 +2184,6 @@ class Process : public std::enable_shared_from_this<Process>,
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);
Expand Down
1 change: 0 additions & 1 deletion lldb/include/lldb/lldb-forward.h
Expand Up @@ -43,7 +43,6 @@ class BreakpointSiteList;
class BroadcastEventSpec;
class Broadcaster;
class BroadcasterManager;
class CPPLanguageRuntime;
class ClangASTContext;
class ClangASTImporter;
class ClangASTMetadata;
Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
Expand Up @@ -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;
Expand Down
Expand Up @@ -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();
Expand Down
10 changes: 0 additions & 10 deletions lldb/source/Target/Process.cpp
Expand Up @@ -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 =
Expand Down

0 comments on commit 29975a2

Please sign in to comment.