aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-04-14 21:41:27 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-06-22 18:20:56 +0000
commitbdd1243df58e60e85101c09001d9812a789b6bc4 (patch)
treea1ce621c7301dd47ba2ddc3b8eaa63b441389481 /contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
parent781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff)
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp b/contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
index 905e9637493b..06eb6ff9cafb 100644
--- a/contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
+++ b/contrib/llvm-project/lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
@@ -24,6 +24,7 @@
#include "llvm/BinaryFormat/Wasm.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Format.h"
+#include <optional>
using namespace lldb;
using namespace lldb_private;
@@ -49,7 +50,7 @@ static bool ValidateModuleHeader(const DataBufferSP &data_sp) {
return version == llvm::wasm::WasmVersion;
}
-static llvm::Optional<ConstString>
+static std::optional<ConstString>
GetWasmString(llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) {
// A Wasm string is encoded as a vector of UTF-8 codes.
// Vectors are encoded with their u32 length followed by the element
@@ -57,21 +58,21 @@ GetWasmString(llvm::DataExtractor &data, llvm::DataExtractor::Cursor &c) {
uint64_t len = data.getULEB128(c);
if (!c) {
consumeError(c.takeError());
- return llvm::None;
+ return std::nullopt;
}
if (len >= (uint64_t(1) << 32)) {
- return llvm::None;
+ return std::nullopt;
}
llvm::SmallVector<uint8_t, 32> str_storage;
data.getU8(c, str_storage, len);
if (!c) {
consumeError(c.takeError());
- return llvm::None;
+ return std::nullopt;
}
- llvm::StringRef str = toStringRef(makeArrayRef(str_storage));
+ llvm::StringRef str = toStringRef(llvm::ArrayRef(str_storage));
return ConstString(str);
}
@@ -181,7 +182,7 @@ bool ObjectFileWasm::DecodeNextSection(lldb::offset_t *offset_ptr) {
// identifying the custom section, followed by an uninterpreted sequence
// of bytes.
lldb::offset_t prev_offset = c.tell();
- llvm::Optional<ConstString> sect_name = GetWasmString(data, c);
+ std::optional<ConstString> sect_name = GetWasmString(data, c);
if (!sect_name)
return false;
@@ -412,7 +413,7 @@ DataExtractor ObjectFileWasm::ReadImageData(offset_t offset, uint32_t size) {
return data;
}
-llvm::Optional<FileSpec> ObjectFileWasm::GetExternalDebugInfoFileSpec() {
+std::optional<FileSpec> ObjectFileWasm::GetExternalDebugInfoFileSpec() {
static ConstString g_sect_name_external_debug_info("external_debug_info");
for (const section_info &sect_info : m_sect_infos) {
@@ -422,12 +423,12 @@ llvm::Optional<FileSpec> ObjectFileWasm::GetExternalDebugInfoFileSpec() {
ReadImageData(sect_info.offset, kBufferSize);
llvm::DataExtractor data = section_header_data.GetAsLLVM();
llvm::DataExtractor::Cursor c(0);
- llvm::Optional<ConstString> symbols_url = GetWasmString(data, c);
+ std::optional<ConstString> symbols_url = GetWasmString(data, c);
if (symbols_url)
return FileSpec(symbols_url->GetStringRef());
}
}
- return llvm::None;
+ return std::nullopt;
}
void ObjectFileWasm::Dump(Stream *s) {