From 29975a2a5d050d1c6a7220844efe8706d1376eb4 Mon Sep 17 00:00:00 2001 From: Alex Langford Date: Tue, 4 Jun 2019 20:14:33 +0000 Subject: [PATCH] [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 --- lldb/include/lldb/Target/CPPLanguageRuntime.h | 5 +++++ lldb/include/lldb/Target/Process.h | 2 -- lldb/include/lldb/lldb-forward.h | 1 - lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp | 3 ++- .../LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp | 2 +- lldb/source/Target/Process.cpp | 10 ---------- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/lldb/include/lldb/Target/CPPLanguageRuntime.h b/lldb/include/lldb/Target/CPPLanguageRuntime.h index 8de8853..f035bac 100644 --- a/lldb/include/lldb/Target/CPPLanguageRuntime.h +++ b/lldb/include/lldb/Target/CPPLanguageRuntime.h @@ -43,6 +43,11 @@ public: return lldb::eLanguageTypeC_plus_plus; } + static CPPLanguageRuntime *GetCPPLanguageRuntime(Process &process) { + return static_cast( + process.GetLanguageRuntime(lldb::eLanguageTypeC_plus_plus)); + } + virtual bool IsVTableName(const char *name) = 0; bool GetObjectDescription(Stream &str, ValueObject &object) override; diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 2657302..c3ffa99 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -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); diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index ebebd47..fd2d272 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -43,7 +43,6 @@ class BreakpointSiteList; class BroadcastEventSpec; class Broadcaster; class BroadcasterManager; -class CPPLanguageRuntime; class ClangASTContext; class ClangASTImporter; class ClangASTMetadata; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 9dceca6..01b3a7e 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -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; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 8a0b5bf..7ea3d6b 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -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(); diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 1d1fda1..b46ded4 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1598,16 +1598,6 @@ LanguageRuntime *Process::GetLanguageRuntime(lldb::LanguageType language, return runtime; } -CPPLanguageRuntime *Process::GetCPPLanguageRuntime(bool retry_if_null) { - std::lock_guard guard(m_language_runtimes_mutex); - LanguageRuntime *runtime = - GetLanguageRuntime(eLanguageTypeC_plus_plus, retry_if_null); - if (!runtime) - return nullptr; - - return static_cast(runtime); -} - ObjCLanguageRuntime *Process::GetObjCLanguageRuntime(bool retry_if_null) { std::lock_guard guard(m_language_runtimes_mutex); LanguageRuntime *runtime = -- 2.7.4