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 --- .../gdb-remote/GDBRemoteCommunicationClient.cpp | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp') diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 7442f48..6e47e5b 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -956,7 +956,7 @@ llvm::VersionTuple GDBRemoteCommunicationClient::GetMacCatalystVersion() { return m_maccatalyst_version; } -llvm::Optional GDBRemoteCommunicationClient::GetOSBuildString() { +std::optional GDBRemoteCommunicationClient::GetOSBuildString() { if (GetHostInfo()) { if (!m_os_build.empty()) return m_os_build; @@ -964,7 +964,7 @@ llvm::Optional GDBRemoteCommunicationClient::GetOSBuildString() { return std::nullopt; } -llvm::Optional +std::optional GDBRemoteCommunicationClient::GetOSKernelDescription() { if (GetHostInfo()) { if (!m_os_kernel.empty()) @@ -2688,10 +2688,8 @@ bool GDBRemoteCommunicationClient::KillSpawnedProcess(lldb::pid_t pid) { return false; } -llvm::Optional -GDBRemoteCommunicationClient::SendSetCurrentThreadPacket(uint64_t tid, - uint64_t pid, - char op) { +std::optional GDBRemoteCommunicationClient::SendSetCurrentThreadPacket( + uint64_t tid, uint64_t pid, char op) { lldb_private::StreamString packet; packet.PutChar('H'); packet.PutChar(op); @@ -2729,7 +2727,7 @@ bool GDBRemoteCommunicationClient::SetCurrentThread(uint64_t tid, (m_curr_pid == pid || LLDB_INVALID_PROCESS_ID == pid)) return true; - llvm::Optional ret = SendSetCurrentThreadPacket(tid, pid, 'g'); + std::optional ret = SendSetCurrentThreadPacket(tid, pid, 'g'); if (ret) { if (ret->pid != LLDB_INVALID_PROCESS_ID) m_curr_pid = ret->pid; @@ -2744,7 +2742,7 @@ bool GDBRemoteCommunicationClient::SetCurrentThreadForRun(uint64_t tid, (m_curr_pid_run == pid || LLDB_INVALID_PROCESS_ID == pid)) return true; - llvm::Optional ret = SendSetCurrentThreadPacket(tid, pid, 'c'); + std::optional ret = SendSetCurrentThreadPacket(tid, pid, 'c'); if (ret) { if (ret->pid != LLDB_INVALID_PROCESS_ID) m_curr_pid_run = ret->pid; @@ -3088,7 +3086,7 @@ bool GDBRemoteCommunicationClient::CloseFile(lldb::user_id_t fd, return false; } -llvm::Optional +std::optional GDBRemoteCommunicationClient::FStat(lldb::user_id_t fd) { lldb_private::StreamString stream; stream.Printf("vFile:fstat:%" PRIx64, fd); @@ -3112,13 +3110,13 @@ GDBRemoteCommunicationClient::FStat(lldb::user_id_t fd) { return std::nullopt; } -llvm::Optional +std::optional GDBRemoteCommunicationClient::Stat(const lldb_private::FileSpec &file_spec) { Status error; lldb::user_id_t fd = OpenFile(file_spec, File::eOpenOptionReadOnly, 0, error); if (fd == UINT64_MAX) return std::nullopt; - llvm::Optional st = FStat(fd); + std::optional st = FStat(fd); CloseFile(fd, error); return st; } @@ -3146,7 +3144,7 @@ lldb::user_id_t GDBRemoteCommunicationClient::GetFileSize( } // Fallback to fstat. - llvm::Optional st = Stat(file_spec); + std::optional st = Stat(file_spec); return st ? st->gdb_st_size : UINT64_MAX; } @@ -3217,7 +3215,7 @@ GDBRemoteCommunicationClient::GetFilePermissions(const FileSpec &file_spec, } // Fallback to fstat. - if (llvm::Optional st = Stat(file_spec)) { + if (std::optional st = Stat(file_spec)) { file_permissions = st->gdb_st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); return Status(); } @@ -3720,7 +3718,7 @@ GDBRemoteCommunicationClient::SendTraceGetBinaryData( escaped_packet.GetData()); } -llvm::Optional GDBRemoteCommunicationClient::GetQOffsets() { +std::optional GDBRemoteCommunicationClient::GetQOffsets() { StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse("qOffsets", response) != PacketResult::Success) @@ -3826,7 +3824,7 @@ bool GDBRemoteCommunicationClient::GetModuleInfo( return true; } -static llvm::Optional +static std::optional ParseModuleSpec(StructuredData::Dictionary *dict) { ModuleSpec result; if (!dict) @@ -3859,7 +3857,7 @@ ParseModuleSpec(StructuredData::Dictionary *dict) { return result; } -llvm::Optional> +std::optional> GDBRemoteCommunicationClient::GetModulesInfo( llvm::ArrayRef module_file_specs, const llvm::Triple &triple) { namespace json = llvm::json; @@ -3906,7 +3904,7 @@ GDBRemoteCommunicationClient::GetModulesInfo( std::vector result; for (size_t i = 0; i < response_array->GetSize(); ++i) { - if (llvm::Optional module_spec = ParseModuleSpec( + if (std::optional module_spec = ParseModuleSpec( response_array->GetItemAtIndex(i)->GetAsDictionary())) result.push_back(*module_spec); } -- cgit v1.1