From 2fe8327406050d2585d2ced910a678e28caefcf5 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 7 Jan 2023 14:18:35 -0800 Subject: [lldb] Use std::optional instead of llvm::Optional (NFC) This patch replaces (llvm::|)Optional< with std::optional<. I'll post a separate patch to clean up the "using" declarations, #include "llvm/ADT/Optional.h", etc. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 --- lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h | 4 ++-- .../Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp | 4 ++-- .../ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp | 6 +++--- .../ScriptInterpreter/Python/ScriptedProcessPythonInterface.h | 4 ++-- .../Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp | 4 ++-- .../Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h | 4 ++-- .../ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp | 7 +++---- .../ScriptInterpreter/Python/ScriptedThreadPythonInterface.h | 6 +++--- 8 files changed, 19 insertions(+), 20 deletions(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h index a09dfb4..35c9621 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h @@ -212,7 +212,7 @@ bool LLDBSWIGPythonRunScriptKeywordProcess(const char *python_function_name, const lldb::ProcessSP &process, std::string &output); -llvm::Optional +std::optional LLDBSWIGPythonRunScriptKeywordThread(const char *python_function_name, const char *session_dictionary_name, lldb::ThreadSP thread); @@ -222,7 +222,7 @@ bool LLDBSWIGPythonRunScriptKeywordTarget(const char *python_function_name, const lldb::TargetSP &target, std::string &output); -llvm::Optional +std::optional LLDBSWIGPythonRunScriptKeywordFrame(const char *python_function_name, const char *session_dictionary_name, lldb::StackFrameSP frame); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 3cff7fa..7101db0 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -2426,7 +2426,7 @@ bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword( Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - if (llvm::Optional result = LLDBSWIGPythonRunScriptKeywordThread( + if (std::optional result = LLDBSWIGPythonRunScriptKeywordThread( impl_function, m_dictionary_name.c_str(), thread->shared_from_this())) { output = std::move(*result); @@ -2475,7 +2475,7 @@ bool ScriptInterpreterPythonImpl::RunScriptFormatKeyword( Locker py_lock(this, Locker::AcquireLock | Locker::InitSession | Locker::NoSTDIN); - if (llvm::Optional result = LLDBSWIGPythonRunScriptKeywordFrame( + if (std::optional result = LLDBSWIGPythonRunScriptKeywordFrame( impl_function, m_dictionary_name.c_str(), frame->shared_from_this())) { output = std::move(*result); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp index 311da2b..5fd085d 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp @@ -76,10 +76,10 @@ Status ScriptedProcessPythonInterface::Stop() { return GetStatusFromMethod("stop"); } -llvm::Optional +std::optional ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress( lldb::addr_t address, Status &error) { - auto mem_region = Dispatch>( + auto mem_region = Dispatch>( "get_memory_region_containing_address", error, address); if (error.Fail()) { @@ -170,7 +170,7 @@ bool ScriptedProcessPythonInterface::IsAlive() { return obj->GetBooleanValue(); } -llvm::Optional +std::optional ScriptedProcessPythonInterface::GetScriptedThreadPluginName() { Status error; StructuredData::ObjectSP obj = Dispatch("get_scripted_thread_plugin", error); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h index 680b833..6b4ee30 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h @@ -37,7 +37,7 @@ public: Status Stop() override; - llvm::Optional + std::optional GetMemoryRegionContainingAddress(lldb::addr_t address, Status &error) override; @@ -56,7 +56,7 @@ public: bool IsAlive() override; - llvm::Optional GetScriptedThreadPluginName() override; + std::optional GetScriptedThreadPluginName() override; StructuredData::DictionarySP GetMetadata() override; diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp index ee90666..10c22df 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp @@ -80,9 +80,9 @@ ScriptedPythonInterface::ExtractValueFromPythonObject( } template <> -llvm::Optional +std::optional ScriptedPythonInterface::ExtractValueFromPythonObject< - llvm::Optional>(python::PythonObject &p, Status &error) { + std::optional>(python::PythonObject &p, Status &error) { lldb::SBMemoryRegionInfo *sb_mem_reg_info = reinterpret_cast( diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h index 6d77a0a..cc936e0 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h @@ -198,9 +198,9 @@ ScriptedPythonInterface::ExtractValueFromPythonObject( python::PythonObject &p, Status &error); template <> -llvm::Optional +std::optional ScriptedPythonInterface::ExtractValueFromPythonObject< - llvm::Optional>(python::PythonObject &p, Status &error); + std::optional>(python::PythonObject &p, Status &error); } // namespace lldb_private diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp index 2df3325..21d2ed3 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp @@ -71,7 +71,7 @@ lldb::tid_t ScriptedThreadPythonInterface::GetThreadID() { return obj->GetIntegerValue(LLDB_INVALID_THREAD_ID); } -llvm::Optional ScriptedThreadPythonInterface::GetName() { +std::optional ScriptedThreadPythonInterface::GetName() { Status error; StructuredData::ObjectSP obj = Dispatch("get_name", error); @@ -91,7 +91,7 @@ lldb::StateType ScriptedThreadPythonInterface::GetState() { return static_cast(obj->GetIntegerValue(eStateInvalid)); } -llvm::Optional ScriptedThreadPythonInterface::GetQueue() { +std::optional ScriptedThreadPythonInterface::GetQueue() { Status error; StructuredData::ObjectSP obj = Dispatch("get_queue", error); @@ -134,8 +134,7 @@ StructuredData::DictionarySP ScriptedThreadPythonInterface::GetRegisterInfo() { return dict; } -llvm::Optional -ScriptedThreadPythonInterface::GetRegisterContext() { +std::optional ScriptedThreadPythonInterface::GetRegisterContext() { Status error; StructuredData::ObjectSP obj = Dispatch("get_register_context", error); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h index 3b7fec6..eac4941 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h @@ -30,11 +30,11 @@ public: lldb::tid_t GetThreadID() override; - llvm::Optional GetName() override; + std::optional GetName() override; lldb::StateType GetState() override; - llvm::Optional GetQueue() override; + std::optional GetQueue() override; StructuredData::DictionarySP GetStopReason() override; @@ -42,7 +42,7 @@ public: StructuredData::DictionarySP GetRegisterInfo() override; - llvm::Optional GetRegisterContext() override; + std::optional GetRegisterContext() override; StructuredData::ArraySP GetExtendedInfo() override; }; -- cgit v1.1