aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lldb/source/Expression/Materializer.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/Expression/Materializer.cpp
parent781624ca2d054430052c828ba8d2c2eaf2d733e7 (diff)
parente3b557809604d036af6e00c60f012c2025b59a5e (diff)
Diffstat (limited to 'contrib/llvm-project/lldb/source/Expression/Materializer.cpp')
-rw-r--r--contrib/llvm-project/lldb/source/Expression/Materializer.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/contrib/llvm-project/lldb/source/Expression/Materializer.cpp b/contrib/llvm-project/lldb/source/Expression/Materializer.cpp
index 946ae10d69c2..0932dc6f95b1 100644
--- a/contrib/llvm-project/lldb/source/Expression/Materializer.cpp
+++ b/contrib/llvm-project/lldb/source/Expression/Materializer.cpp
@@ -25,6 +25,7 @@
#include "lldb/lldb-forward.h"
#include <memory>
+#include <optional>
using namespace lldb_private;
@@ -543,7 +544,7 @@ public:
return;
}
- llvm::Optional<size_t> opt_bit_align = GetTypeBitAlign(scope);
+ std::optional<size_t> opt_bit_align = GetTypeBitAlign(scope);
if (!opt_bit_align) {
err.SetErrorStringWithFormat("can't get the type alignment for %s",
GetName().AsCString());
@@ -773,8 +774,8 @@ private:
/// Returns size in bytes of the type associated with this variable
///
/// \returns On success, returns byte size of the type associated
- /// with this variable. Returns NoneType otherwise.
- virtual llvm::Optional<uint64_t>
+ /// with this variable. Returns std::nullopt otherwise.
+ virtual std::optional<uint64_t>
GetByteSize(ExecutionContextScope *scope) const = 0;
/// Returns 'true' if the location expression associated with this variable
@@ -784,8 +785,8 @@ private:
/// Returns alignment of the type associated with this variable in bits.
///
/// \returns On success, returns alignment in bits for the type associated
- /// with this variable. Returns NoneType otherwise.
- virtual llvm::Optional<size_t>
+ /// with this variable. Returns std::nullopt otherwise.
+ virtual std::optional<size_t>
GetTypeBitAlign(ExecutionContextScope *scope) const = 0;
protected:
@@ -815,7 +816,7 @@ public:
return ValueObjectVariable::Create(scope, m_variable_sp);
}
- llvm::Optional<uint64_t>
+ std::optional<uint64_t>
GetByteSize(ExecutionContextScope *scope) const override {
return m_variable_sp->GetType()->GetByteSize(scope);
}
@@ -824,7 +825,7 @@ public:
return m_variable_sp->LocationExpressionList().IsValid();
}
- llvm::Optional<size_t>
+ std::optional<size_t>
GetTypeBitAlign(ExecutionContextScope *scope) const override {
return m_variable_sp->GetType()->GetLayoutCompilerType().GetTypeBitAlign(
scope);
@@ -858,7 +859,7 @@ public:
return m_valobj_sp;
}
- llvm::Optional<uint64_t>
+ std::optional<uint64_t>
GetByteSize(ExecutionContextScope *scope) const override {
if (m_valobj_sp)
return m_valobj_sp->GetCompilerType().GetByteSize(scope);
@@ -873,7 +874,7 @@ public:
return false;
}
- llvm::Optional<size_t>
+ std::optional<size_t>
GetTypeBitAlign(ExecutionContextScope *scope) const override {
if (m_valobj_sp)
return m_valobj_sp->GetCompilerType().GetTypeBitAlign(scope);
@@ -934,14 +935,14 @@ public:
if (!exe_scope)
exe_scope = map.GetBestExecutionContextScope();
- llvm::Optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope);
+ std::optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope);
if (!byte_size) {
err.SetErrorStringWithFormat("can't get size of type \"%s\"",
m_type.GetTypeName().AsCString());
return;
}
- llvm::Optional<size_t> opt_bit_align = m_type.GetTypeBitAlign(exe_scope);
+ std::optional<size_t> opt_bit_align = m_type.GetTypeBitAlign(exe_scope);
if (!opt_bit_align) {
err.SetErrorStringWithFormat("can't get the alignment of type \"%s\"",
m_type.GetTypeName().AsCString());
@@ -1023,8 +1024,15 @@ public:
llvm::toString(std::move(error)).c_str());
return;
}
+ auto ts = *type_system_or_err;
+ if (!ts) {
+ err.SetErrorStringWithFormat("Couldn't dematerialize a result variable: "
+ "couldn't corresponding type system is "
+ "no longer live.");
+ return;
+ }
PersistentExpressionState *persistent_state =
- type_system_or_err->GetPersistentExpressionState();
+ ts->GetPersistentExpressionState();
if (!persistent_state) {
err.SetErrorString("Couldn't dematerialize a result variable: "