diff options
author | Kazu Hirata <kazu@google.com> | 2023-01-07 14:18:35 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2023-01-07 14:18:35 -0800 |
commit | 2fe8327406050d2585d2ced910a678e28caefcf5 (patch) | |
tree | da95c78fa33c17cf7829bbe6f5e0bfa62e0579ae /lldb/source/Plugins/ScriptInterpreter/Python | |
parent | f190ce625ab0dc5a5e2b2515e6d26debb34843ab (diff) | |
download | llvm-2fe8327406050d2585d2ced910a678e28caefcf5.zip llvm-2fe8327406050d2585d2ced910a678e28caefcf5.tar.gz llvm-2fe8327406050d2585d2ced910a678e28caefcf5.tar.bz2 |
[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
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
8 files changed, 19 insertions, 20 deletions
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::string> +std::optional<std::string> 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::string> +std::optional<std::string> 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<std::string> result = LLDBSWIGPythonRunScriptKeywordThread( + if (std::optional<std::string> 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<std::string> result = LLDBSWIGPythonRunScriptKeywordFrame( + if (std::optional<std::string> 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<MemoryRegionInfo> +std::optional<MemoryRegionInfo> ScriptedProcessPythonInterface::GetMemoryRegionContainingAddress( lldb::addr_t address, Status &error) { - auto mem_region = Dispatch<llvm::Optional<MemoryRegionInfo>>( + auto mem_region = Dispatch<std::optional<MemoryRegionInfo>>( "get_memory_region_containing_address", error, address); if (error.Fail()) { @@ -170,7 +170,7 @@ bool ScriptedProcessPythonInterface::IsAlive() { return obj->GetBooleanValue(); } -llvm::Optional<std::string> +std::optional<std::string> 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<MemoryRegionInfo> + std::optional<MemoryRegionInfo> GetMemoryRegionContainingAddress(lldb::addr_t address, Status &error) override; @@ -56,7 +56,7 @@ public: bool IsAlive() override; - llvm::Optional<std::string> GetScriptedThreadPluginName() override; + std::optional<std::string> 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<lldb::DataExtractorSP>( } template <> -llvm::Optional<MemoryRegionInfo> +std::optional<MemoryRegionInfo> ScriptedPythonInterface::ExtractValueFromPythonObject< - llvm::Optional<MemoryRegionInfo>>(python::PythonObject &p, Status &error) { + std::optional<MemoryRegionInfo>>(python::PythonObject &p, Status &error) { lldb::SBMemoryRegionInfo *sb_mem_reg_info = reinterpret_cast<lldb::SBMemoryRegionInfo *>( 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<lldb::DataExtractorSP>( python::PythonObject &p, Status &error); template <> -llvm::Optional<MemoryRegionInfo> +std::optional<MemoryRegionInfo> ScriptedPythonInterface::ExtractValueFromPythonObject< - llvm::Optional<MemoryRegionInfo>>(python::PythonObject &p, Status &error); + std::optional<MemoryRegionInfo>>(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<std::string> ScriptedThreadPythonInterface::GetName() { +std::optional<std::string> ScriptedThreadPythonInterface::GetName() { Status error; StructuredData::ObjectSP obj = Dispatch("get_name", error); @@ -91,7 +91,7 @@ lldb::StateType ScriptedThreadPythonInterface::GetState() { return static_cast<StateType>(obj->GetIntegerValue(eStateInvalid)); } -llvm::Optional<std::string> ScriptedThreadPythonInterface::GetQueue() { +std::optional<std::string> ScriptedThreadPythonInterface::GetQueue() { Status error; StructuredData::ObjectSP obj = Dispatch("get_queue", error); @@ -134,8 +134,7 @@ StructuredData::DictionarySP ScriptedThreadPythonInterface::GetRegisterInfo() { return dict; } -llvm::Optional<std::string> -ScriptedThreadPythonInterface::GetRegisterContext() { +std::optional<std::string> 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<std::string> GetName() override; + std::optional<std::string> GetName() override; lldb::StateType GetState() override; - llvm::Optional<std::string> GetQueue() override; + std::optional<std::string> GetQueue() override; StructuredData::DictionarySP GetStopReason() override; @@ -42,7 +42,7 @@ public: StructuredData::DictionarySP GetRegisterInfo() override; - llvm::Optional<std::string> GetRegisterContext() override; + std::optional<std::string> GetRegisterContext() override; StructuredData::ArraySP GetExtendedInfo() override; }; |