summaryrefslogtreecommitdiff
path: root/lldb/tools
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2023-01-07 14:18:35 -0800
committerKazu Hirata <kazu@google.com>2023-01-07 14:18:35 -0800
commit2fe8327406050d2585d2ced910a678e28caefcf5 (patch)
treeda95c78fa33c17cf7829bbe6f5e0bfa62e0579ae /lldb/tools
parentf190ce625ab0dc5a5e2b2515e6d26debb34843ab (diff)
downloadllvm-2fe8327406050d2585d2ced910a678e28caefcf5.tar.gz
[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/tools')
-rw-r--r--lldb/tools/lldb-server/Acceptor.cpp2
-rw-r--r--lldb/tools/lldb-server/lldb-platform.cpp2
-rw-r--r--lldb/tools/lldb-test/lldb-test.cpp4
-rw-r--r--lldb/tools/lldb-vscode/FifoFiles.cpp2
-rw-r--r--lldb/tools/lldb-vscode/JSONUtils.cpp8
-rw-r--r--lldb/tools/lldb-vscode/JSONUtils.h8
-rw-r--r--lldb/tools/lldb-vscode/ProgressEvent.cpp18
-rw-r--r--lldb/tools/lldb-vscode/ProgressEvent.h10
8 files changed, 27 insertions, 27 deletions
diff --git a/lldb/tools/lldb-server/Acceptor.cpp b/lldb/tools/lldb-server/Acceptor.cpp
index 0b69350c1acc..2037f1e0f62b 100644
--- a/lldb/tools/lldb-server/Acceptor.cpp
+++ b/lldb/tools/lldb-server/Acceptor.cpp
@@ -86,7 +86,7 @@ std::unique_ptr<Acceptor> Acceptor::Create(StringRef name,
Socket::SocketProtocol socket_protocol = Socket::ProtocolUnixDomain;
// Try to match socket name as URL - e.g., tcp://localhost:5555
- if (llvm::Optional<URI> res = URI::Parse(name)) {
+ if (std::optional<URI> res = URI::Parse(name)) {
if (!FindProtocolByScheme(res->scheme.str().c_str(), socket_protocol))
error.SetErrorStringWithFormat("Unknown protocol scheme \"%s\"",
res->scheme.str().c_str());
diff --git a/lldb/tools/lldb-server/lldb-platform.cpp b/lldb/tools/lldb-server/lldb-platform.cpp
index fb37aa6f6175..21b433511c56 100644
--- a/lldb/tools/lldb-server/lldb-platform.cpp
+++ b/lldb/tools/lldb-server/lldb-platform.cpp
@@ -353,7 +353,7 @@ int main_platform(int argc, char *argv[]) {
if (platform.IsConnected()) {
if (inferior_arguments.GetArgumentCount() > 0) {
lldb::pid_t pid = LLDB_INVALID_PROCESS_ID;
- llvm::Optional<uint16_t> port = 0;
+ std::optional<uint16_t> port = 0;
std::string socket_name;
Status error = platform.LaunchGDBServer(inferior_arguments,
"", // hostname
diff --git a/lldb/tools/lldb-test/lldb-test.cpp b/lldb/tools/lldb-test/lldb-test.cpp
index 6bd8585bdabe..d9c30b4f2ed8 100644
--- a/lldb/tools/lldb-test/lldb-test.cpp
+++ b/lldb/tools/lldb-test/lldb-test.cpp
@@ -141,7 +141,7 @@ static cl::opt<std::string> InputFile(cl::Positional, cl::desc("<input file>"),
cl::Required, cl::sub(SymTabSubcommand));
/// Validate that the options passed make sense.
-static llvm::Optional<llvm::Error> validate();
+static std::optional<llvm::Error> validate();
/// Transforms the selected mangling preference into a Mangled::NamePreference
static Mangled::NamePreference getNamePreference();
@@ -861,7 +861,7 @@ Expected<Error (*)(lldb_private::Module &)> opts::symbols::getAction() {
llvm_unreachable("Unsupported symbol action.");
}
-llvm::Optional<llvm::Error> opts::symtab::validate() {
+std::optional<llvm::Error> opts::symtab::validate() {
if (ManglingPreference != ManglingPreference::None &&
FindSymbolsByRegex.empty())
return make_string_error("Mangling preference set but no regex specified.");
diff --git a/lldb/tools/lldb-vscode/FifoFiles.cpp b/lldb/tools/lldb-vscode/FifoFiles.cpp
index 18354bfabcea..a5330d58c36c 100644
--- a/lldb/tools/lldb-vscode/FifoFiles.cpp
+++ b/lldb/tools/lldb-vscode/FifoFiles.cpp
@@ -53,7 +53,7 @@ FifoFileIO::FifoFileIO(StringRef fifo_file, StringRef other_endpoint_name)
Expected<json::Value> FifoFileIO::ReadJSON(std::chrono::milliseconds timeout) {
// We use a pointer for this future, because otherwise its normal destructor
// would wait for the getline to end, rendering the timeout useless.
- Optional<std::string> line;
+ std::optional<std::string> line;
std::future<void> *future =
new std::future<void>(std::async(std::launch::async, [&]() {
std::ifstream reader(m_fifo_file, std::ifstream::in);
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 06d5c28c2a1b..82f591148811 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -308,8 +308,8 @@ llvm::json::Value CreateScope(const llvm::StringRef name,
// "required": [ "verified" ]
// }
llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp,
- llvm::Optional<llvm::StringRef> request_path,
- llvm::Optional<uint32_t> request_line) {
+ std::optional<llvm::StringRef> request_path,
+ std::optional<uint32_t> request_line) {
// Each breakpoint location is treated as a separate breakpoint for VS code.
// They don't have the notion of a single breakpoint with multiple locations.
llvm::json::Object object;
@@ -440,8 +440,8 @@ llvm::json::Value CreateModule(lldb::SBModule &module) {
}
void AppendBreakpoint(lldb::SBBreakpoint &bp, llvm::json::Array &breakpoints,
- llvm::Optional<llvm::StringRef> request_path,
- llvm::Optional<uint32_t> request_line) {
+ std::optional<llvm::StringRef> request_path,
+ std::optional<uint32_t> request_line) {
breakpoints.emplace_back(CreateBreakpoint(bp, request_path, request_line));
}
diff --git a/lldb/tools/lldb-vscode/JSONUtils.h b/lldb/tools/lldb-vscode/JSONUtils.h
index 64c1a4c3d554..b67da7191cde 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.h
+++ b/lldb/tools/lldb-vscode/JSONUtils.h
@@ -211,8 +211,8 @@ void SetValueForKey(lldb::SBValue &v, llvm::json::Object &object,
/// fallback.
void AppendBreakpoint(
lldb::SBBreakpoint &bp, llvm::json::Array &breakpoints,
- llvm::Optional<llvm::StringRef> request_path = std::nullopt,
- llvm::Optional<uint32_t> request_line = std::nullopt);
+ std::optional<llvm::StringRef> request_path = std::nullopt,
+ std::optional<uint32_t> request_line = std::nullopt);
/// Converts breakpoint location to a Visual Studio Code "Breakpoint"
///
@@ -237,8 +237,8 @@ void AppendBreakpoint(
/// definition outlined by Microsoft.
llvm::json::Value
CreateBreakpoint(lldb::SBBreakpoint &bp,
- llvm::Optional<llvm::StringRef> request_path = std::nullopt,
- llvm::Optional<uint32_t> request_line = std::nullopt);
+ std::optional<llvm::StringRef> request_path = std::nullopt,
+ std::optional<uint32_t> request_line = std::nullopt);
/// Converts a LLDB module to a VS Code DAP module for use in "modules" events.
///
diff --git a/lldb/tools/lldb-vscode/ProgressEvent.cpp b/lldb/tools/lldb-vscode/ProgressEvent.cpp
index 57658768eac1..443d04892b42 100644
--- a/lldb/tools/lldb-vscode/ProgressEvent.cpp
+++ b/lldb/tools/lldb-vscode/ProgressEvent.cpp
@@ -22,7 +22,8 @@ const std::chrono::duration<double> kStartProgressEventReportDelay =
const std::chrono::duration<double> kUpdateProgressEventReportDelay =
std::chrono::milliseconds(250);
-ProgressEvent::ProgressEvent(uint64_t progress_id, Optional<StringRef> message,
+ProgressEvent::ProgressEvent(uint64_t progress_id,
+ std::optional<StringRef> message,
uint64_t completed, uint64_t total,
const ProgressEvent *prev_event)
: m_progress_id(progress_id) {
@@ -63,11 +64,10 @@ ProgressEvent::ProgressEvent(uint64_t progress_id, Optional<StringRef> message,
}
}
-Optional<ProgressEvent> ProgressEvent::Create(uint64_t progress_id,
- Optional<StringRef> message,
- uint64_t completed,
- uint64_t total,
- const ProgressEvent *prev_event) {
+std::optional<ProgressEvent>
+ProgressEvent::Create(uint64_t progress_id, std::optional<StringRef> message,
+ uint64_t completed, uint64_t total,
+ const ProgressEvent *prev_event) {
// If it's an update without a previous event, we abort
if (completed > 0 && completed < total && !prev_event)
return std::nullopt;
@@ -163,7 +163,7 @@ const ProgressEvent &ProgressEventManager::GetMostRecentEvent() const {
void ProgressEventManager::Update(uint64_t progress_id, uint64_t completed,
uint64_t total) {
- if (Optional<ProgressEvent> event = ProgressEvent::Create(
+ if (std::optional<ProgressEvent> event = ProgressEvent::Create(
progress_id, std::nullopt, completed, total, &GetMostRecentEvent())) {
if (event->GetEventType() == progressEnd)
m_finished = true;
@@ -216,8 +216,8 @@ void ProgressEventReporter::Push(uint64_t progress_id, const char *message,
auto it = m_event_managers.find(progress_id);
if (it == m_event_managers.end()) {
- if (Optional<ProgressEvent> event =
- ProgressEvent::Create(progress_id, StringRef(message), completed, total)) {
+ if (std::optional<ProgressEvent> event = ProgressEvent::Create(
+ progress_id, StringRef(message), completed, total)) {
ProgressEventManagerSP event_manager =
std::make_shared<ProgressEventManager>(*event, m_report_callback);
m_event_managers.insert({progress_id, event_manager});
diff --git a/lldb/tools/lldb-vscode/ProgressEvent.h b/lldb/tools/lldb-vscode/ProgressEvent.h
index 376c4a320768..85006e4c0a81 100644
--- a/lldb/tools/lldb-vscode/ProgressEvent.h
+++ b/lldb/tools/lldb-vscode/ProgressEvent.h
@@ -47,8 +47,8 @@ public:
/// \param[in] prev_event
/// Previous event if this one is an update. If \b nullptr, then a start
/// event will be created.
- static llvm::Optional<ProgressEvent>
- Create(uint64_t progress_id, llvm::Optional<llvm::StringRef> message,
+ static std::optional<ProgressEvent>
+ Create(uint64_t progress_id, std::optional<llvm::StringRef> message,
uint64_t completed, uint64_t total,
const ProgressEvent *prev_event = nullptr);
@@ -71,14 +71,14 @@ public:
bool Reported() const;
private:
- ProgressEvent(uint64_t progress_id, llvm::Optional<llvm::StringRef> message,
+ ProgressEvent(uint64_t progress_id, std::optional<llvm::StringRef> message,
uint64_t completed, uint64_t total,
const ProgressEvent *prev_event);
uint64_t m_progress_id;
std::string m_message;
ProgressEventType m_event_type;
- llvm::Optional<uint32_t> m_percentage;
+ std::optional<uint32_t> m_percentage;
std::chrono::duration<double> m_creation_time =
std::chrono::system_clock::now().time_since_epoch();
std::chrono::duration<double> m_minimum_allowed_report_time;
@@ -113,7 +113,7 @@ public:
private:
ProgressEvent m_start_event;
- llvm::Optional<ProgressEvent> m_last_update_event;
+ std::optional<ProgressEvent> m_last_update_event;
bool m_finished;
ProgressEventReportCallback m_report_callback;
};