[Lldb-commits] [lldb] [lldb] All ValueObjectSP instances are now valid (non-null) but have an error state (In-progress | Take 2) (PR #77375)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jan 8 13:09:06 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: Pete Lawrence (PortalPete)
<details>
<summary>Changes</summary>
> **Note**
> I originally proposed this change with [PR 74912](https://github.com/llvm/llvm-project/pull/74912) before renaming the branch.
### Purpose
For now, we'd like to get people's thought's on the goal, design, and scope of this PR by reviewing these preliminary changes.
I recommend focussing (or starting) on these files:
* `ValueObject.h`
* `ValueObject.cpp`
### Goal
Every `ValueObjectSP` will have an actual value and will never be equal to `nullptr`.
### Design
To force each `ValueObjectSP` to contain _something_, we're considering changing the type from a typedef…
```cpp
typedef std::shared_ptr<lldb_private::ValueObject> ValueObjectSP;
```
to this subclass:
```cpp
class ValueObjectSP : public std::shared_ptr<lldb_private::ValueObject> {
ValueObjectSP() = delete;
operator bool() = delete;
public:
ValueObjectSP(std::shared_ptr<lldb_private::ValueObject> &&pointer)
: std::shared_ptr<lldb_private::ValueObject>(std::move(pointer)) {
assert(pointer);
}
};
```
This class removes the default constructor to force each `ValueObjectSP` to point to a real `ValueObject` instance. It also removes `operator bool()` because no instance will ever equal `nullptr`.
### Change Patterns
The bulk of the changes into one of these two camps:
1. For methods that have a `Status &error` parameter **and** return an `ValueObjectSP`, the return value *becomes* the container for the error state, which eliminate the need for a parameter.
* This means that callers of these methods need to check the return value's error state.
* `return_value->GetError.Success()`
* `return_value->GetError.Fail()`
2. For all other methods that return a `ValueObjectSP` but don't have a `Status &` parameter, they now return `std::optional<ValueObjectSP>`.
* This changes a fair amount of code in these ways:
* Code which had been using the `std::shared_ptr` Boolean operator now uses the `std::optional` Boolean operator.
* Nearby code has to call the optional's `value()` method to get the shared pointer inside.
* Methods with lines that return `ValueObjectSP()` now return `{}`, which creates an optional with nothing in it.
Again, I recommend focussing (or starting) on these files:
* `ValueObject.h`
* `ValueObject.cpp`
### Remaining work
This is very much a work-in-progress for a proof of concept, which means:
* It doesn't compile (yet)
* So far I've modified 53 files
* I estimate another 100-250 more files need to change based on the ninja build progress indicator.
The remaining changes will just be more of the same but now's a good time to take a look at this sample to get a sense of the magnitude and trajectory of the remaining changes.
---
Patch is 203.61 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/77375.diff
53 Files Affected:
- (modified) lldb/include/lldb/Breakpoint/Watchpoint.h (+2-2)
- (modified) lldb/include/lldb/Core/ValueObject.h (+38-28)
- (modified) lldb/include/lldb/Core/ValueObjectConstResult.h (+4-4)
- (modified) lldb/include/lldb/Core/ValueObjectConstResultCast.h (+3-3)
- (modified) lldb/include/lldb/Core/ValueObjectConstResultChild.h (+3-3)
- (modified) lldb/include/lldb/Core/ValueObjectConstResultImpl.h (+4-4)
- (modified) lldb/include/lldb/Core/ValueObjectList.h (+10-7)
- (modified) lldb/include/lldb/Core/ValueObjectRegister.h (+2-2)
- (modified) lldb/include/lldb/Core/ValueObjectSyntheticFilter.h (+5-5)
- (modified) lldb/include/lldb/Core/ValueObjectUpdater.h (+3-3)
- (modified) lldb/include/lldb/DataFormatters/TypeSynthetic.h (+12-10)
- (modified) lldb/include/lldb/DataFormatters/ValueObjectPrinter.h (+2-1)
- (modified) lldb/include/lldb/DataFormatters/VectorIterator.h (+1-1)
- (modified) lldb/include/lldb/Expression/ExpressionVariable.h (+37-16)
- (modified) lldb/include/lldb/Expression/UserExpression.h (+1-1)
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+4-4)
- (modified) lldb/include/lldb/Target/LanguageRuntime.h (+3-3)
- (modified) lldb/include/lldb/Target/StackFrame.h (+6-6)
- (modified) lldb/include/lldb/Target/StackFrameRecognizer.h (+1-3)
- (modified) lldb/include/lldb/Target/Target.h (+1-1)
- (modified) lldb/include/lldb/Target/Thread.h (+2-2)
- (modified) lldb/include/lldb/Target/ThreadPlan.h (+2-2)
- (modified) lldb/include/lldb/Target/ThreadPlanCallFunction.h (+1-1)
- (modified) lldb/include/lldb/lldb-forward.h (+12-1)
- (modified) lldb/source/Breakpoint/BreakpointLocation.cpp (+2-4)
- (modified) lldb/source/Breakpoint/Watchpoint.cpp (+13-9)
- (modified) lldb/source/Commands/CommandObjectDWIMPrint.cpp (+12-11)
- (modified) lldb/source/Commands/CommandObjectExpression.cpp (+14-11)
- (modified) lldb/source/Commands/CommandObjectFrame.cpp (+19-17)
- (modified) lldb/source/Commands/CommandObjectMemory.cpp (+9-16)
- (modified) lldb/source/Commands/CommandObjectTarget.cpp (+3-4)
- (modified) lldb/source/Commands/CommandObjectThread.cpp (+5-10)
- (modified) lldb/source/Commands/CommandObjectType.cpp (+7-5)
- (modified) lldb/source/Commands/CommandObjectWatchpoint.cpp (+9-9)
- (modified) lldb/source/Core/FormatEntity.cpp (+15-14)
- (modified) lldb/source/Core/IOHandlerCursesGUI.cpp (+16-13)
- (modified) lldb/source/Core/ValueObject.cpp (+312-328)
- (modified) lldb/source/Core/ValueObjectConstResult.cpp (+11-9)
- (modified) lldb/source/Core/ValueObjectConstResultCast.cpp (+6-5)
- (modified) lldb/source/Core/ValueObjectConstResultChild.cpp (+6-5)
- (modified) lldb/source/Core/ValueObjectConstResultImpl.cpp (+32-17)
- (modified) lldb/source/Core/ValueObjectList.cpp (+30-35)
- (modified) lldb/source/Core/ValueObjectRegister.cpp (+2-2)
- (modified) lldb/source/Core/ValueObjectSyntheticFilter.cpp (+24-22)
- (modified) lldb/source/Core/ValueObjectUpdater.cpp (+9-9)
- (modified) lldb/source/DataFormatters/FormatManager.cpp (+20-17)
- (modified) lldb/source/DataFormatters/TypeSynthetic.cpp (+14-12)
- (modified) lldb/source/DataFormatters/ValueObjectPrinter.cpp (+14-12)
- (modified) lldb/source/DataFormatters/VectorType.cpp (+6-8)
- (modified) lldb/source/Expression/ExpressionVariable.cpp (+9-5)
- (modified) lldb/source/Target/StackFrame.cpp (+191-177)
- (modified) lldb/source/Target/Target.cpp (+1-1)
- (modified) lldb/source/Target/Thread.cpp (+13-10)
``````````diff
diff --git a/lldb/include/lldb/Breakpoint/Watchpoint.h b/lldb/include/lldb/Breakpoint/Watchpoint.h
index 851162af24c74e0..78b81218bfcf450 100644
--- a/lldb/include/lldb/Breakpoint/Watchpoint.h
+++ b/lldb/include/lldb/Breakpoint/Watchpoint.h
@@ -219,8 +219,8 @@ class Watchpoint : public std::enable_shared_from_this<Watchpoint>,
uint32_t m_ignore_count; // Number of times to ignore this watchpoint
std::string m_decl_str; // Declaration information, if any.
std::string m_watch_spec_str; // Spec for the watchpoint.
- lldb::ValueObjectSP m_old_value_sp;
- lldb::ValueObjectSP m_new_value_sp;
+ std::optional<lldb::ValueObjectSP> m_old_value_sp;
+ std::optional<lldb::ValueObjectSP> m_new_value_sp;
CompilerType m_type;
Status m_error; // An error object describing errors associated with this
// watchpoint.
diff --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index 3f8005ba696ce84..0f1b8c98aee1df3 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -409,7 +409,7 @@ class ValueObject {
Stream &s,
GetExpressionPathFormat = eGetExpressionPathFormatDereferencePointers);
- lldb::ValueObjectSP GetValueForExpressionPath(
+ std::optional<lldb::ValueObjectSP> GetValueForExpressionPath(
llvm::StringRef expression,
ExpressionPathScanEndReason *reason_to_stop = nullptr,
ExpressionPathEndResultType *final_value_type = nullptr,
@@ -465,14 +465,18 @@ class ValueObject {
/// Returns a unique id for this ValueObject.
lldb::user_id_t GetID() const { return m_id.GetID(); }
- virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx,
- bool can_create = true);
+ virtual std::optional<lldb::ValueObjectSP>
+ GetChildAtIndex(size_t idx, bool can_create = true);
- // The method always creates missing children in the path, if necessary.
- lldb::ValueObjectSP GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names);
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
bool can_create = true);
+ /// The method always creates missing children in the path, if necessary.
+ std::optional<lldb::ValueObjectSP>
+ GetChildAtNamePath(llvm::ArrayRef<llvm::StringRef> names);
+
+ virtual std::optional<lldb::ValueObjectSP>
+ GetChildMemberWithName(llvm::StringRef name, bool can_create = true);
virtual size_t GetIndexOfChildWithName(llvm::StringRef name);
@@ -536,7 +540,11 @@ class ValueObject {
bool UpdateFormatsIfNeeded();
- lldb::ValueObjectSP GetSP() { return m_manager->GetSharedPointer(this); }
+ lldb::ValueObjectSP GetSP() {
+ auto shared_pointer = m_manager->GetSharedPointer(this);
+ lldb::ValueObjectSP value_object_sp(std::move(shared_pointer));
+ return value_object_sp;
+ }
/// Change the name of the current ValueObject. Should *not* be used from a
/// synthetic child provider as it would change the name of the non synthetic
@@ -548,26 +556,28 @@ class ValueObject {
lldb::addr_t GetPointerValue(AddressType *address_type = nullptr);
- lldb::ValueObjectSP GetSyntheticChild(ConstString key) const;
+ std::optional<lldb::ValueObjectSP> GetSyntheticChild(ConstString key) const;
- lldb::ValueObjectSP GetSyntheticArrayMember(size_t index, bool can_create);
+ std::optional<lldb::ValueObjectSP> GetSyntheticArrayMember(size_t index,
+ bool can_create);
- lldb::ValueObjectSP GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
- bool can_create);
+ std::optional<lldb::ValueObjectSP>
+ GetSyntheticBitFieldChild(uint32_t from, uint32_t to, bool can_create);
- lldb::ValueObjectSP GetSyntheticExpressionPathChild(const char *expression,
- bool can_create);
+ std::optional<lldb::ValueObjectSP>
+ GetSyntheticExpressionPathChild(const char *expression, bool can_create);
- virtual lldb::ValueObjectSP
+ virtual std::optional<lldb::ValueObjectSP>
GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
bool can_create,
ConstString name_const_str = ConstString());
- virtual lldb::ValueObjectSP
+ virtual std::optional<lldb::ValueObjectSP>
GetSyntheticBase(uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str = ConstString());
- virtual lldb::ValueObjectSP GetDynamicValue(lldb::DynamicValueType valueType);
+ virtual std::optional<lldb::ValueObjectSP>
+ GetDynamicValue(lldb::DynamicValueType valueType);
lldb::DynamicValueType GetDynamicValueType();
@@ -575,7 +585,7 @@ class ValueObject {
virtual lldb::ValueObjectSP GetNonSyntheticValue() { return GetSP(); }
- lldb::ValueObjectSP GetSyntheticValue();
+ std::optional<lldb::ValueObjectSP> GetSyntheticValue();
virtual bool HasSyntheticValue();
@@ -587,7 +597,7 @@ class ValueObject {
virtual lldb::ValueObjectSP CreateConstantValue(ConstString name);
- virtual lldb::ValueObjectSP Dereference(Status &error);
+ virtual lldb::ValueObjectSP Dereference();
/// Creates a copy of the ValueObject with a new name and setting the current
/// ValueObject as its parent. It should be used when we want to change the
@@ -595,7 +605,7 @@ class ValueObject {
/// (e.g. sythetic child provider).
virtual lldb::ValueObjectSP Clone(ConstString new_name);
- virtual lldb::ValueObjectSP AddressOf(Status &error);
+ virtual lldb::ValueObjectSP AddressOf();
virtual lldb::addr_t GetLiveAddress() { return LLDB_INVALID_ADDRESS; }
@@ -606,11 +616,11 @@ class ValueObject {
virtual lldb::ValueObjectSP DoCast(const CompilerType &compiler_type);
- virtual lldb::ValueObjectSP CastPointerType(const char *name,
- CompilerType &ast_type);
+ virtual std::optional<lldb::ValueObjectSP>
+ CastPointerType(const char *name, CompilerType &ast_type);
- virtual lldb::ValueObjectSP CastPointerType(const char *name,
- lldb::TypeSP &type_sp);
+ virtual std::optional<lldb::ValueObjectSP>
+ CastPointerType(const char *name, lldb::TypeSP &type_sp);
/// If this object represents a C++ class with a vtable, return an object
/// that represents the virtual function table. If the object isn't a class
@@ -642,18 +652,18 @@ class ValueObject {
void Dump(Stream &s, const DumpValueObjectOptions &options);
- static lldb::ValueObjectSP
+ static std::optional<lldb::ValueObjectSP>
CreateValueObjectFromExpression(llvm::StringRef name,
llvm::StringRef expression,
const ExecutionContext &exe_ctx);
- static lldb::ValueObjectSP
+ static std::optional<lldb::ValueObjectSP>
CreateValueObjectFromExpression(llvm::StringRef name,
llvm::StringRef expression,
const ExecutionContext &exe_ctx,
const EvaluateExpressionOptions &options);
- static lldb::ValueObjectSP
+ static std::optional<lldb::ValueObjectSP>
CreateValueObjectFromAddress(llvm::StringRef name, uint64_t address,
const ExecutionContext &exe_ctx,
CompilerType type);
@@ -662,7 +672,7 @@ class ValueObject {
CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
const ExecutionContext &exe_ctx, CompilerType type);
- lldb::ValueObjectSP Persist();
+ std::optional<lldb::ValueObjectSP> Persist();
/// Returns true if this is a char* or a char[] if it is a char* and
/// check_pointer is true, it also checks that the pointer is valid.
@@ -874,7 +884,7 @@ class ValueObject {
/// We have to hold onto a shared pointer to this one because it is created
/// as an independent ValueObjectConstResult, which isn't managed by us.
- lldb::ValueObjectSP m_addr_of_valobj_sp;
+ std::optional<lldb::ValueObjectSP> m_addr_of_valobj_sp;
lldb::Format m_format = lldb::eFormatDefault;
lldb::Format m_last_format = lldb::eFormatDefault;
@@ -998,7 +1008,7 @@ class ValueObject {
GetRoot()->DoUpdateChildrenAddressType(*this);
}
- lldb::ValueObjectSP GetValueForExpressionPath_Impl(
+ std::optional<lldb::ValueObjectSP> GetValueForExpressionPath_Impl(
llvm::StringRef expression_cstr,
ExpressionPathScanEndReason *reason_to_stop,
ExpressionPathEndResultType *final_value_type,
diff --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h
index d61df859bebce4c..2fedb0f99f0af4b 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResult.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResult.h
@@ -77,16 +77,16 @@ class ValueObjectConstResult : public ValueObject {
void SetByteSize(size_t size);
- lldb::ValueObjectSP Dereference(Status &error) override;
+ lldb::ValueObjectSP Dereference() override;
ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index) override;
- lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ std::optional<lldb::ValueObjectSP> GetSyntheticChildAtOffset(
uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str = ConstString()) override;
- lldb::ValueObjectSP AddressOf(Status &error) override;
+ lldb::ValueObjectSP AddressOf() override;
lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
AddressType *address_type = nullptr) override;
@@ -101,7 +101,7 @@ class ValueObjectConstResult : public ValueObject {
m_impl.SetLiveAddress(addr, address_type);
}
- lldb::ValueObjectSP
+ std::optional<lldb::ValueObjectSP>
GetDynamicValue(lldb::DynamicValueType valueType) override;
lldb::LanguageType GetPreferredDisplayLanguage() override;
diff --git a/lldb/include/lldb/Core/ValueObjectConstResultCast.h b/lldb/include/lldb/Core/ValueObjectConstResultCast.h
index efcbe0dc6a0bd9f..8c36320125bbc9b 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResultCast.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResultCast.h
@@ -33,7 +33,7 @@ class ValueObjectConstResultCast : public ValueObjectCast {
~ValueObjectConstResultCast() override;
- lldb::ValueObjectSP Dereference(Status &error) override;
+ lldb::ValueObjectSP Dereference() override;
ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index) override;
@@ -42,11 +42,11 @@ class ValueObjectConstResultCast : public ValueObjectCast {
return ValueObjectCast::GetCompilerType();
}
- lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ std::optional<lldb::ValueObjectSP> GetSyntheticChildAtOffset(
uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str = ConstString()) override;
- lldb::ValueObjectSP AddressOf(Status &error) override;
+ lldb::ValueObjectSP AddressOf() override;
size_t GetPointeeData(DataExtractor &data, uint32_t item_idx = 0,
uint32_t item_count = 1) override;
diff --git a/lldb/include/lldb/Core/ValueObjectConstResultChild.h b/lldb/include/lldb/Core/ValueObjectConstResultChild.h
index 7e9da14e8e97f76..b58e0995086ce60 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResultChild.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResultChild.h
@@ -39,7 +39,7 @@ class ValueObjectConstResultChild : public ValueObjectChild {
~ValueObjectConstResultChild() override;
- lldb::ValueObjectSP Dereference(Status &error) override;
+ lldb::ValueObjectSP Dereference() override;
ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index) override;
@@ -48,11 +48,11 @@ class ValueObjectConstResultChild : public ValueObjectChild {
return ValueObjectChild::GetCompilerType();
}
- lldb::ValueObjectSP GetSyntheticChildAtOffset(
+ std::optional<lldb::ValueObjectSP> GetSyntheticChildAtOffset(
uint32_t offset, const CompilerType &type, bool can_create,
ConstString name_const_str = ConstString()) override;
- lldb::ValueObjectSP AddressOf(Status &error) override;
+ lldb::ValueObjectSP AddressOf() override;
lldb::addr_t GetAddressOf(bool scalar_is_load_address = true,
AddressType *address_type = nullptr) override;
diff --git a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h
index 5a7a079d3095c93..19a4c206f7a9b79 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResultImpl.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResultImpl.h
@@ -36,17 +36,17 @@ class ValueObjectConstResultImpl {
virtual ~ValueObjectConstResultImpl() = default;
- lldb::ValueObjectSP Dereference(Status &error);
+ lldb::ValueObjectSP Dereference();
ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index);
- lldb::ValueObjectSP
+ std::optional<lldb::ValueObjectSP>
GetSyntheticChildAtOffset(uint32_t offset, const CompilerType &type,
bool can_create,
ConstString name_const_str = ConstString());
- lldb::ValueObjectSP AddressOf(Status &error);
+ lldb::ValueObjectSP AddressOf();
lldb::addr_t GetLiveAddress() { return m_live_address; }
@@ -68,7 +68,7 @@ class ValueObjectConstResultImpl {
ValueObject *m_impl_backend;
lldb::addr_t m_live_address;
AddressType m_live_address_type;
- lldb::ValueObjectSP m_address_of_backend;
+ std::optional<lldb::ValueObjectSP> m_address_of_backend;
ValueObjectConstResultImpl(const ValueObjectConstResultImpl &) = delete;
const ValueObjectConstResultImpl &
diff --git a/lldb/include/lldb/Core/ValueObjectList.h b/lldb/include/lldb/Core/ValueObjectList.h
index fcb358e21a26b4a..42b7d64d6a36c89 100644
--- a/lldb/include/lldb/Core/ValueObjectList.h
+++ b/lldb/include/lldb/Core/ValueObjectList.h
@@ -28,31 +28,34 @@ class ValueObjectList {
void Append(const ValueObjectList &valobj_list);
- lldb::ValueObjectSP FindValueObjectByPointer(ValueObject *valobj);
+ std::optional<lldb::ValueObjectSP>
+ FindValueObjectByPointer(ValueObject *valobj);
size_t GetSize() const;
void Resize(size_t size);
- lldb::ValueObjectSP GetValueObjectAtIndex(size_t idx);
+ std::optional<lldb::ValueObjectSP> GetValueObjectAtIndex(size_t idx);
- lldb::ValueObjectSP RemoveValueObjectAtIndex(size_t idx);
+ std::optional<lldb::ValueObjectSP> RemoveValueObjectAtIndex(size_t idx);
void SetValueObjectAtIndex(size_t idx, const lldb::ValueObjectSP &valobj_sp);
- lldb::ValueObjectSP FindValueObjectByValueName(const char *name);
+ std::optional<lldb::ValueObjectSP>
+ FindValueObjectByValueName(const char *name);
- lldb::ValueObjectSP FindValueObjectByUID(lldb::user_id_t uid);
+ std::optional<lldb::ValueObjectSP> FindValueObjectByUID(lldb::user_id_t uid);
void Swap(ValueObjectList &value_object_list);
void Clear() { m_value_objects.clear(); }
- const std::vector<lldb::ValueObjectSP> &GetObjects() const {
+ const std::vector<std::optional<lldb::ValueObjectSP>> &GetObjects() const {
return m_value_objects;
}
+
protected:
- typedef std::vector<lldb::ValueObjectSP> collection;
+ typedef std::vector<std::optional<lldb::ValueObjectSP>> collection;
// Classes that inherit from ValueObjectList can see and modify these
collection m_value_objects;
};
diff --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h
index 2e47eee3d7f793f..b4f6cad3b817f6b 100644
--- a/lldb/include/lldb/Core/ValueObjectRegister.h
+++ b/lldb/include/lldb/Core/ValueObjectRegister.h
@@ -52,8 +52,8 @@ class ValueObjectRegisterSet : public ValueObject {
ValueObject *CreateChildAtIndex(size_t idx, bool synthetic_array_member,
int32_t synthetic_index) override;
- lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
- bool can_create = true) override;
+ std::optional<lldb::ValueObjectSP>
+ GetChildMemberWithName(llvm::StringRef name, bool can_create = true) override;
size_t GetIndexOfChildWithName(llvm::StringRef name) override;
diff --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
index 67596232eafd1e9..127db2857f684d9 100644
--- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -51,15 +51,15 @@ class ValueObjectSynthetic : public ValueObject {
lldb::ValueType GetValueType() const override;
- lldb::ValueObjectSP GetChildAtIndex(size_t idx,
- bool can_create = true) override;
+ std::optional<lldb::ValueObjectSP>
+ GetChildAtIndex(size_t idx, bool can_create = true) override;
- lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
- bool can_create = true) override;
+ std::optional<lldb::ValueObjectSP>
+ GetChildMemberWithName(llvm::StringRef name, bool can_create = true) override;
size_t GetIndexOfChildWithName(llvm::StringRef name) override;
- lldb::ValueObjectSP
+ std::optional<lldb::ValueObjectSP>
GetDynamicValue(lldb::DynamicValueType valueType) override;
bool IsInScope() override;
diff --git a/lldb/include/lldb/Core/ValueObjectUpdater.h b/lldb/include/lldb/Core/ValueObjectUpdater.h
index 54fcb31076added..52ccf9416cbe852 100644
--- a/lldb/include/lldb/Core/ValueObjectUpdater.h
+++ b/lldb/include/lldb/Core/ValueObjectUpdater.h
@@ -20,9 +20,9 @@ namespace lldb_private {
/// process' stop ID and will update the user type when needed.
class ValueObjectUpdater {
/// The root value object is the static typed variable object.
- lldb::ValueObjectSP m_root_valobj_sp;
+ std::optional<lldb::ValueObjectSP> m_root_valobj_sp;
/// The user value object is the value object the user wants to see.
- lldb::ValueObjectSP m_user_valobj_sp;
+ std::optional<lldb::ValueObjectSP> m_user_valobj_sp;
/// The stop ID that m_user_valobj_sp is valid for.
uint32_t m_stop_id = UINT32_MAX;
@@ -33,7 +33,7 @@ class ValueObjectUpdater {
/// stop ID. If dynamic values are enabled, or if synthetic children are
/// enabled, the value object that the user wants to see might change while
/// debugging.
- lldb::ValueObjectSP GetSP();
+ std::optional<lldb::ValueObjectSP> GetSP();
lldb::ProcessSP GetProcessSP() const;
};
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index 41be9b7efda8fdb..be88b44aed962a7 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -45,7 +45,7 @@ class SyntheticChildrenFrontEnd {
return count <= max ? count : max;
}
- virtual lldb::ValueObjectSP GetChildAtIndex(size_t idx) = 0;
+ virtual std::optional<lldb::ValueObjectSP> GetChildAtIndex(size_t idx) = 0;
virtual size_t GetIndexOfChildWithName(ConstString name) = 0;
@@ -68,7 +68,7 @@ class SyntheticChildrenFrontEnd {
// if this function returns a non-null ValueObject, then the returned
// ValueObject will stand for this ValueObject whenever a "value" request is
// made to this ValueObject
- virtual lldb::ValueObjectSP GetSyntheticValue() { return nullptr; }
+ virtual std::optional<lldb::ValueObjectSP> GetSyntheticValue() { return {}; }
// if this function returns a non-empty ConstString, then clients are
// expected to use the return as the name of the type of this ValueObject for
@@ -79,12 +79,12 @@ class SyntheticChildrenFrontEnd {
typedef std::unique_ptr<SyntheticChildrenFrontEnd> AutoPointer;
protected:
- lldb::ValueObjectSP
+ std::optional<lldb::ValueObjectSP>
CreateValueObjectFromExpression(llvm::StringRef name,
llvm::StringRef expression,
con...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/77375
More information about the lldb-commits
mailing list