-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[lldb] Upgrade GetIndexOfChildWithName
to use llvm::Expected
#136693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[lldb] Upgrade GetIndexOfChildWithName
to use llvm::Expected
#136693
Conversation
@llvm/pr-subscribers-lldb Author: Charles Zablit (charles-zablit) ChangesThis patch replaces the use of Patch is 66.88 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/136693.diff 52 Files Affected:
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index 75d20a4378f09..69c50ab038e5b 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -13,6 +13,8 @@
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBType.h"
+#include "lldb/Core/Value.h"
+
class ValueImpl;
class ValueLocker;
diff --git a/lldb/include/lldb/DataFormatters/TypeSynthetic.h b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
index 14e516964f250..a132c63a93b08 100644
--- a/lldb/include/lldb/DataFormatters/TypeSynthetic.h
+++ b/lldb/include/lldb/DataFormatters/TypeSynthetic.h
@@ -51,7 +51,7 @@ class SyntheticChildrenFrontEnd {
virtual lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) = 0;
- virtual size_t GetIndexOfChildWithName(ConstString name) = 0;
+ virtual llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) = 0;
/// This function is assumed to always succeed and if it fails, the front-end
/// should know to deal with it in the correct way (most probably, by refusing
@@ -117,8 +117,9 @@ class SyntheticValueProviderFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ValueObjectSP GetChildAtIndex(uint32_t idx) override { return nullptr; }
- size_t GetIndexOfChildWithName(ConstString name) override {
- return UINT32_MAX;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
}
lldb::ChildCacheState Update() override {
@@ -343,7 +344,7 @@ class TypeFilterImpl : public SyntheticChildren {
bool MightHaveChildren() override { return filter->GetCount() > 0; }
- size_t GetIndexOfChildWithName(ConstString name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
typedef std::shared_ptr<SyntheticChildrenFrontEnd> SharedPointer;
@@ -442,7 +443,7 @@ class ScriptedSyntheticChildren : public SyntheticChildren {
bool MightHaveChildren() override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
lldb::ValueObjectSP GetSyntheticValue() override;
diff --git a/lldb/include/lldb/DataFormatters/VectorIterator.h b/lldb/include/lldb/DataFormatters/VectorIterator.h
index d095f085cabab..bdfaca7349c6a 100644
--- a/lldb/include/lldb/DataFormatters/VectorIterator.h
+++ b/lldb/include/lldb/DataFormatters/VectorIterator.h
@@ -30,7 +30,7 @@ class VectorIteratorSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ChildCacheState Update() override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
private:
ExecutionContextRef m_exe_ctx_ref;
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 25e82779f05c6..5425e58f0d594 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -368,10 +368,11 @@ class ScriptInterpreter : public PluginInterface {
return lldb::ValueObjectSP();
}
- virtual int
+ virtual llvm::Expected<int>
GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor,
const char *child_name) {
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ child_name);
}
virtual bool
diff --git a/lldb/include/lldb/Symbol/CompilerType.h b/lldb/include/lldb/Symbol/CompilerType.h
index 41a1676dabd76..539a4cae04e1c 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -450,8 +450,9 @@ class CompilerType {
/// Lookup a child given a name. This function will match base class names and
/// member member names in "clang_type" only, not descendants.
- uint32_t GetIndexOfChildWithName(llvm::StringRef name,
- bool omit_empty_base_classes) const;
+ llvm::Expected<uint32_t>
+ GetIndexOfChildWithName(llvm::StringRef name,
+ bool omit_empty_base_classes) const;
/// Lookup a child member given a name. This function will match member names
/// only and will descend into "clang_type" children in search for the first
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h
index 59fb066e087d3..0881c47cbaa1a 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -375,9 +375,10 @@ class TypeSystem : public PluginInterface,
// Lookup a child given a name. This function will match base class names and
// member member names in "clang_type" only, not descendants.
- virtual uint32_t GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
- llvm::StringRef name,
- bool omit_empty_base_classes) = 0;
+ virtual llvm::Expected<uint32_t>
+ GetIndexOfChildWithName(lldb::opaque_compiler_type_t type,
+ llvm::StringRef name,
+ bool omit_empty_base_classes) = 0;
// Lookup a child member given a name. This function will match member names
// only and will descend into "clang_type" children in search for the first
diff --git a/lldb/include/lldb/ValueObject/ValueObject.h b/lldb/include/lldb/ValueObject/ValueObject.h
index 06d2589002ed0..0add8ebeccdc8 100644
--- a/lldb/include/lldb/ValueObject/ValueObject.h
+++ b/lldb/include/lldb/ValueObject/ValueObject.h
@@ -498,7 +498,7 @@ class ValueObject {
virtual lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
bool can_create = true);
- virtual size_t GetIndexOfChildWithName(llvm::StringRef name);
+ virtual llvm::Expected<size_t> GetIndexOfChildWithName(llvm::StringRef name);
llvm::Expected<uint32_t> GetNumChildren(uint32_t max = UINT32_MAX);
/// Like \c GetNumChildren but returns 0 on error. You probably
diff --git a/lldb/include/lldb/ValueObject/ValueObjectRegister.h b/lldb/include/lldb/ValueObject/ValueObjectRegister.h
index 0812dc575aaa1..3db4b00bd1b15 100644
--- a/lldb/include/lldb/ValueObject/ValueObjectRegister.h
+++ b/lldb/include/lldb/ValueObject/ValueObjectRegister.h
@@ -52,7 +52,7 @@ class ValueObjectRegisterSet : public ValueObject {
lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
bool can_create = true) override;
- size_t GetIndexOfChildWithName(llvm::StringRef name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(llvm::StringRef name) override;
protected:
bool UpdateValue() override;
diff --git a/lldb/include/lldb/ValueObject/ValueObjectSyntheticFilter.h b/lldb/include/lldb/ValueObject/ValueObjectSyntheticFilter.h
index df205a258a997..cdb2b1ddc3646 100644
--- a/lldb/include/lldb/ValueObject/ValueObjectSyntheticFilter.h
+++ b/lldb/include/lldb/ValueObject/ValueObjectSyntheticFilter.h
@@ -57,7 +57,7 @@ class ValueObjectSynthetic : public ValueObject {
lldb::ValueObjectSP GetChildMemberWithName(llvm::StringRef name,
bool can_create = true) override;
- size_t GetIndexOfChildWithName(llvm::StringRef name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(llvm::StringRef name) override;
lldb::ValueObjectSP
GetDynamicValue(lldb::DynamicValueType valueType) override;
diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 6b91120f6427a..7b23484023ab3 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -704,13 +704,17 @@ SBValue SBValue::GetChildAtIndex(uint32_t idx,
uint32_t SBValue::GetIndexOfChildWithName(const char *name) {
LLDB_INSTRUMENT_VA(this, name);
- uint32_t idx = UINT32_MAX;
ValueLocker locker;
lldb::ValueObjectSP value_sp(GetSP(locker));
if (value_sp) {
- idx = value_sp->GetIndexOfChildWithName(name);
+ auto idx_or_err = value_sp->GetIndexOfChildWithName(name);
+ if (!idx_or_err) {
+ llvm::consumeError(idx_or_err.takeError());
+ return UINT32_MAX;
+ }
+ return *idx_or_err;
}
- return idx;
+ return UINT32_MAX;
}
SBValue SBValue::GetChildMemberWithName(const char *name) {
diff --git a/lldb/source/DataFormatters/FormatterBytecode.cpp b/lldb/source/DataFormatters/FormatterBytecode.cpp
index 7f3dbe0dba37d..5d65c3043427f 100644
--- a/lldb/source/DataFormatters/FormatterBytecode.cpp
+++ b/lldb/source/DataFormatters/FormatterBytecode.cpp
@@ -14,6 +14,7 @@
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatProviders.h"
#include "llvm/Support/FormatVariadicDetails.h"
+#include <lldb/ValueObject/ValueObjectConstResult.h>
using namespace lldb;
namespace lldb_private {
@@ -489,7 +490,13 @@ llvm::Error Interpret(std::vector<ControlStackElement> &control,
TYPE_CHECK(Object, String);
auto name = data.Pop<std::string>();
POP_VALOBJ(valobj);
- data.Push((uint64_t)valobj->GetIndexOfChildWithName(name));
+ auto index_or_err = valobj->GetIndexOfChildWithName(name);
+ if (!index_or_err) {
+ data.Push(ValueObjectConstResult::Create(
+ nullptr, Status::FromError(index_or_err.takeError())));
+ break;
+ }
+ data.Push((uint64_t)*index_or_err);
break;
}
case sel_get_type: {
diff --git a/lldb/source/DataFormatters/TypeSynthetic.cpp b/lldb/source/DataFormatters/TypeSynthetic.cpp
index 7aa0670190b25..fb23efedbde3d 100644
--- a/lldb/source/DataFormatters/TypeSynthetic.cpp
+++ b/lldb/source/DataFormatters/TypeSynthetic.cpp
@@ -49,7 +49,7 @@ bool TypeFilterImpl::SetExpressionPathAtIndex(size_t i,
return true;
}
-size_t
+llvm::Expected<size_t>
TypeFilterImpl::FrontEnd::GetIndexOfChildWithName(ConstString name) {
const char *name_cstr = name.GetCString();
if (name_cstr) {
@@ -218,10 +218,11 @@ bool ScriptedSyntheticChildren::FrontEnd::MightHaveChildren() {
return m_interpreter->MightHaveChildrenSynthProviderInstance(m_wrapper_sp);
}
-size_t ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(
- ConstString name) {
+llvm::Expected<size_t>
+ScriptedSyntheticChildren::FrontEnd::GetIndexOfChildWithName(ConstString name) {
if (!m_wrapper_sp || m_interpreter == nullptr)
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
return m_interpreter->GetIndexOfChildWithName(m_wrapper_sp,
name.GetCString());
}
diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp
index 162b075ec87d2..2ddd6e9b006fb 100644
--- a/lldb/source/DataFormatters/VectorType.cpp
+++ b/lldb/source/DataFormatters/VectorType.cpp
@@ -269,11 +269,12 @@ class VectorTypeSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
return lldb::ChildCacheState::eRefetch;
}
- size_t GetIndexOfChildWithName(ConstString name) override {
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
const char *item_name = name.GetCString();
uint32_t idx = ExtractIndexFromString(item_name);
if (idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
return idx;
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 6a22501c98aab..6731c96341ac8 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -144,9 +144,10 @@ class BlockPointerSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
return lldb::ChildCacheState::eRefetch;
}
- size_t GetIndexOfChildWithName(ConstString name) override {
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (!m_block_struct_type.IsValid())
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
const bool omit_empty_base_classes = false;
return m_block_struct_type.GetIndexOfChildWithName(name.AsCString(),
@@ -172,8 +173,15 @@ bool lldb_private::formatters::BlockPointerSummaryProvider(
static const ConstString s_FuncPtr_name("__FuncPtr");
- lldb::ValueObjectSP child_sp = synthetic_children->GetChildAtIndex(
- synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name));
+ auto index_or_err =
+ synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name);
+
+ if (!index_or_err) {
+ return false;
+ }
+
+ lldb::ValueObjectSP child_sp =
+ synthetic_children->GetChildAtIndex(*index_or_err);
if (!child_sp) {
return false;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
index 76a10d2393782..0d68b1f4eda1b 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp
@@ -199,10 +199,12 @@ lldb_private::formatters::StdlibCoroutineHandleSyntheticFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}
-size_t StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName(
+llvm::Expected<size_t>
+StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName(
ConstString name) {
if (!m_resume_ptr_sp || !m_destroy_ptr_sp)
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
if (name == ConstString("resume"))
return 0;
@@ -211,7 +213,8 @@ size_t StdlibCoroutineHandleSyntheticFrontEnd::GetIndexOfChildWithName(
if (name == ConstString("promise_ptr") && m_promise_ptr_sp)
return 2;
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
}
SyntheticChildrenFrontEnd *
diff --git a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
index c33c82bd2fc45..fd9445d46e6a0 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/Coroutines.h
@@ -40,7 +40,7 @@ class StdlibCoroutineHandleSyntheticFrontEnd
lldb::ChildCacheState Update() override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
private:
lldb::ValueObjectSP m_resume_ptr_sp;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
index 03671c3efed6f..49c51835d1ed6 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
@@ -28,7 +28,7 @@ class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd {
GenericBitsetFrontEnd(ValueObject &valobj, StdLib stdlib);
- size_t GetIndexOfChildWithName(ConstString name) override {
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
return formatters::ExtractIndexFromString(name.GetCString());
}
diff --git a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
index b224d3e859c84..c6b3c3344ef3a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp
@@ -36,7 +36,7 @@ class GenericOptionalFrontend : public SyntheticChildrenFrontEnd {
GenericOptionalFrontend(ValueObject &valobj, StdLib stdlib);
- size_t GetIndexOfChildWithName(ConstString name) override {
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override {
if (name == "$$dereference$$")
return 0;
return formatters::ExtractIndexFromString(name.GetCString());
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 63620c6bf0ddd..04487f86719ba 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -309,13 +309,15 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}
-size_t lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
+llvm::Expected<size_t>
+lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (name == "__ptr_")
return 0;
if (name == "$$dereference$$")
return 1;
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
}
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::
@@ -407,7 +409,8 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update() {
return lldb::ChildCacheState::eRefetch;
}
-size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
+llvm::Expected<size_t>
+lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
if (name == "pointer")
return 0;
@@ -415,7 +418,8 @@ size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
return 1;
if (name == "$$dereference$$")
return 2;
- return UINT32_MAX;
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
}
bool lldb_private::formatters::LibcxxContainerSummaryProvider(
@@ -456,7 +460,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
if (!l)
return {};
- StringLayout layout = l->GetIndexOfChildWithName("__data_") == 0
+ StringLayout layout = l->GetIndexOfChildWithName("__data_").get() == 0
? StringLayout::DSC
: StringLayout::CSD;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
index 21fbb361eb934..56501302d116f 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
@@ -102,7 +102,7 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ChildCacheState Update() override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
~LibcxxSharedPtrSyntheticFrontEnd() override;
@@ -120,7 +120,7 @@ class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ChildCacheState Update() override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
~LibcxxUniquePtrSyntheticFrontEnd() override;
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
index 3104f33ee80b3..87962d4f33cbd 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -96,7 +96,7 @@ class LibcxxStdAtomicSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
lldb::ChildCacheState Update() override;
- size_t GetIndexOfChildWithName(ConstString name) override;
+ llvm::Expected<size_t> GetIndexOfChildWithName(ConstString name) override;
private:
ValueObject *m_real_child = nullptr;
@@ -130,9 +130,14 @@ lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
return nullptr;
}
-size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
+llvm::Expected<size_t>
+lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
GetIndexOfChildWithName(ConstString name) {
- return name == "Value" ? 0 : UINT32_MAX;
+ if (name == "Value") {
+ return 0;
+ }
+ return llvm::createStringError("Cannot find index of child '%s'",
+ name.AsCString());
}
SyntheticChildrenF...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a first walkthrough
lldb/include/lldb/API/SBValue.h
Outdated
@@ -13,6 +13,8 @@ | |||
#include "lldb/API/SBDefines.h" | |||
#include "lldb/API/SBType.h" | |||
|
|||
#include "lldb/Core/Value.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-by change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover from a modification in SBValue.h
which was not committed.
Removed, thanks!
lldb/source/API/SBValue.cpp
Outdated
auto idx_or_err = value_sp->GetIndexOfChildWithName(name); | ||
if (!idx_or_err) { | ||
llvm::consumeError(idx_or_err.takeError()); | ||
return UINT32_MAX; | ||
} | ||
return *idx_or_err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto idx_or_err = value_sp->GetIndexOfChildWithName(name); | |
if (!idx_or_err) { | |
llvm::consumeError(idx_or_err.takeError()); | |
return UINT32_MAX; | |
} | |
return *idx_or_err; | |
if (auto idx_or_err = value_sp->GetIndexOfChildWithName(name)) { | |
return *idx_or_err; | |
else | |
llvm::consumeError(idx_or_err.takeError()); |
feels a bit easier to read
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
auto index_or_err = valobj->GetIndexOfChildWithName(name); | ||
if (!index_or_err) { | ||
data.Push(ValueObjectConstResult::Create( | ||
nullptr, Status::FromError(index_or_err.takeError()))); | ||
break; | ||
} | ||
data.Push((uint64_t)*index_or_err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto index_or_err = valobj->GetIndexOfChildWithName(name); | |
if (!index_or_err) { | |
data.Push(ValueObjectConstResult::Create( | |
nullptr, Status::FromError(index_or_err.takeError()))); | |
break; | |
} | |
data.Push((uint64_t)*index_or_err); | |
auto index_or_err = valobj->GetIndexOfChildWithName(name); | |
if (!index_or_err) | |
return index_or_err.takeError(); | |
data.Push((uint64_t)*index_or_err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
if (!m_wrapper_sp || m_interpreter == nullptr) | ||
return UINT32_MAX; | ||
return llvm::createStringError("Cannot find index of child '%s'", | ||
name.AsCString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be more descriptive with where the error came from? E.g., "ScriptedSyntheticChildren::FrontEnd cannot find index of child '%s'"? Same with the other places in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up editing the message everywhere it was used, adding 'classname'
at the beginning of each.
ConstString name) { | ||
if (!m_resume_ptr_sp || !m_destroy_ptr_sp) | ||
return UINT32_MAX; | ||
return llvm::createStringError("Cannot find index of child '%s'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets print the pointer values of m_resume_ptr_sp
and m_destroy_ptr_sp
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
@@ -456,7 +460,7 @@ ExtractLibcxxStringInfo(ValueObject &valobj) { | |||
if (!l) | |||
return {}; | |||
|
|||
StringLayout layout = l->GetIndexOfChildWithName("__data_") == 0 | |||
StringLayout layout = l->GetIndexOfChildWithName("__data_").get() == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would compare the underlying pointer value to 0
, aka it's now a nullptr check, which is not what we want. (I'd expect some test-failures...hopefully)
We should do something like this instead:
auto index_or_err = l->GetIndexOfChildWithName("__data_");
if (!index_or_err)
return index_or_err.takeError();
StringLayout layout = *index_or_err == 0 ? StringLayout::DSC : StringLayout::CSD;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
The tests were not failing either here...
if (name == "Value") { | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (name == "Value") { | |
return 0; | |
} | |
if (name == "Value") | |
return 0; |
GetIndexOfChildWithName(ConstString name) { | ||
if (!m_pair_sp) | ||
return UINT32_MAX; | ||
return llvm::createStringError("Cannot find index of child '%s'", | ||
name.AsCString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets add to the error message that we have an invalid underlying pair
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
@@ -173,7 +173,8 @@ lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd::Update() { | |||
return ChildCacheState::eRefetch; | |||
} | |||
|
|||
size_t lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd:: | |||
llvm::Expected<size_t> | |||
lldb_private::formatters::LibcxxStdProxyArraySyntheticFrontEnd:: | |||
GetIndexOfChildWithName(ConstString name) { | |||
if (!m_base) | |||
return std::numeric_limits<size_t>::max(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
if (m_container_sp) { | ||
return m_container_sp->GetIndexOfChildWithName(name); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (m_container_sp) { | |
return m_container_sp->GetIndexOfChildWithName(name); | |
} | |
if (m_container_sp) | |
return m_container_sp->GetIndexOfChildWithName(name); |
|
||
if (index == UINT32_MAX) | ||
if (!index_or_err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to use llvm::consumeError
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
return llvm::createStringError("Cannot find index of child '%s'", | ||
name.AsCString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return llvm::createStringError("Cannot find index of child '%s'", | |
name.AsCString()); | |
return index_or_err.takeError(); |
else /*if (iter != m_name_toindex.end())*/ | ||
return found_index; | ||
return found_index.value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return found_index.value(); | |
return *found_index; |
return UINT32_MAX; | ||
m_name_toindex[name.GetCString()] = *index_or_err; | ||
return *index_or_err; | ||
} else if (!found_index.has_value() && m_synth_filter_up == nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else if (!found_index.has_value() && m_synth_filter_up == nullptr) | |
} else if (!found_index && m_synth_filter_up == nullptr) |
uint32_t index = m_synth_filter_up->GetIndexOfChildWithName(name); | ||
if (index == UINT32_MAX) | ||
return index; | ||
if (!found_index.has_value() && m_synth_filter_up != nullptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!found_index.has_value() && m_synth_filter_up != nullptr) { | |
if (!found_index && m_synth_filter_up != nullptr) { |
@@ -14,6 +14,7 @@ | |||
#include "llvm/Support/Format.h" | |||
#include "llvm/Support/FormatProviders.h" | |||
#include "llvm/Support/FormatVariadicDetails.h" | |||
#include <lldb/ValueObject/ValueObjectConstResult.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For llvm the standard is to include with ""
instead of <>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I'd move this up so so it's next to the other lldb imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
@@ -489,7 +490,10 @@ llvm::Error Interpret(std::vector<ControlStackElement> &control, | |||
TYPE_CHECK(Object, String); | |||
auto name = data.Pop<std::string>(); | |||
POP_VALOBJ(valobj); | |||
data.Push((uint64_t)valobj->GetIndexOfChildWithName(name)); | |||
auto index_or_err = valobj->GetIndexOfChildWithName(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (auto index_or_err = valobj->GetIndexOfChildWithName(name))
data.Push((uint64_t)*index_or_err);
else
return index_or_err.takeError();
auto index_or_err = l->GetIndexOfChildWithName("__data_"); | ||
if (!index_or_err) | ||
LLDB_LOG_ERROR(GetLog(LLDBLog::Types), index_or_err.takeError(), "{0}"); | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is supposed to be inside the if statement body right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was actually the root cause of some test failures as well...
53c97bb
to
4dda702
Compare
@@ -67,7 +67,9 @@ TypeFilterImpl::FrontEnd::GetIndexOfChildWithName(ConstString name) { | |||
} | |||
} | |||
} | |||
return UINT32_MAX; | |||
return llvm::createStringError( | |||
"'SyntheticChildrenFrontEnd::FrontEnd' cannot find index of child '%s'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"'SyntheticChildrenFrontEnd::FrontEnd' cannot find index of child '%s'", | |
"'TypeFilterImpl::FrontEnd' cannot find index of child '%s'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest leaving out the function name entirely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially suggested it because that'd make it easier to identify where this was coming from if we ever decide to log it (or see it in user reports)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Michael137 My thinking is that these error messages are meant to be read by LLDB users, and the function name is a tool to aid in debugging LLDB itself. Users won't understand the meaning of the function name here, so we shouldn't have it in the user-facing error message. If this is useful information needed to debug LLDB, then we should log it instead.
Let me know if you think that's not a good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm fair question. Adding logging to all these places feels a bit noisy. In my opinion its helpful to be as specific as possible, and if we wanted to present something more generic to the user eventually then we can change the error message at the point where we are about to present it. I'm not sure where these error messages will currently show up actually
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding logging to all these places feels a bit noisy.
Currently the error is dropped silently. You wouldn't replace that with adding logging everywhere. My suggestion would be to:
- return errors that are understandable to users
- where necessary add logging in the error case with additional information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where these error messages will currently show up actually
The error messages in the Expected return results of CompilerType are surfaced when formatting ValueObjects, for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm my main concern is that we end up getting user reports with a very generic error and then have no way to really tell where we went wrong. Then adding logging after-the-fact is a pretty slow turnaround. I guess usually these types of issues require a reproducer to debug anyway, so maybe this isn't a valid concern? Wdyt? I don't have a strong opinion on this. But it would be easier/more convenient to go from non-generic error back to generic error than the other way around if we really need to
(idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())) | ||
return llvm::createStringError( | ||
"'SyntheticChildrenFrontEnd::VectorTypeSyntheticFrontEnd' cannot " | ||
"find index of child '%s'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also print the idx
that we found in the error message? (same applies to other places that do the idx >= CalculateNumChildrenIgnoringErrors
comparison)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type has no child named '%s'
name.AsCString(), static_cast<void *>(m_resume_ptr_sp.get()), | ||
static_cast<void *>(m_destroy_ptr_sp.get())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name.AsCString(), static_cast<void *>(m_resume_ptr_sp.get()), | |
static_cast<void *>(m_destroy_ptr_sp.get())); | |
name.AsCString(), m_resume_ptr_sp.get(), | |
m_destroy_ptr_sp.get()); |
lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp
Outdated
Show resolved
Hide resolved
@@ -7159,7 +7159,9 @@ TypeSystemClang::GetIndexOfChildWithName(lldb::opaque_compiler_type_t type, | |||
break; | |||
} | |||
} | |||
return UINT32_MAX; | |||
return llvm::createStringError("'SyntheticChildrenFrontEnd::TypeSystemClang' " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return llvm::createStringError("'SyntheticChildrenFrontEnd::TypeSystemClang' " | |
return llvm::createStringError("'TypeSystemClang' " |
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Symbol/CompilerType.cpp
Outdated
CompilerType::GetIndexOfChildWithName(llvm::StringRef name, | ||
bool omit_empty_base_classes) const { | ||
if (IsValid() && !name.empty()) { | ||
if (auto type_system_sp = GetTypeSystem()) | ||
return type_system_sp->GetIndexOfChildWithName(m_type, name, | ||
omit_empty_base_classes); | ||
} | ||
return UINT32_MAX; | ||
return llvm::createStringError("'SyntheticChildrenFrontEnd::CompilerType' " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return llvm::createStringError("'SyntheticChildrenFrontEnd::CompilerType' " | |
return llvm::createStringError("'CompilerType' " |
if (m_reg_ctx_sp && m_reg_set) { | ||
const RegisterInfo *reg_info = m_reg_ctx_sp->GetRegisterInfoByName(name); | ||
if (reg_info != nullptr) | ||
return reg_info->kinds[eRegisterKindLLDB]; | ||
} | ||
return UINT32_MAX; | ||
return llvm::createStringError( | ||
"'SyntheticChildrenFrontEnd::ValueObjectRegisterSet' cannot find index " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"'SyntheticChildrenFrontEnd::ValueObjectRegisterSet' cannot find index " | |
"'ValueObjectRegisterSet' cannot find index " |
return llvm::createStringError( | ||
"'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index " | ||
"of child '%s'", | ||
name.AsCString()); | ||
else /*if (iter != m_name_toindex.end())*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets be safe and add this condition:
else /*if (iter != m_name_toindex.end())*/ | |
else if (found_index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I left some remaining comments. Should be good to go once those are addressed
return llvm::createStringError("Cannot find index of child '%s'", | ||
name.AsCString()); | ||
return llvm::createStringError( | ||
"'ScriptedSyntheticChildren::LibcxxUniquePtrSyntheticFrontEnd' cannot " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"'ScriptedSyntheticChildren::LibcxxUniquePtrSyntheticFrontEnd' cannot " | |
"'LibcxxUniquePtrSyntheticFrontEnd' cannot " |
return llvm::createStringError("Cannot find index of child '%s'", | ||
name.AsCString()); | ||
return llvm::createStringError( | ||
"'SyntheticChildrenFrontend::LibcxxSharedPtrSyntheticFrontEnd' cannot " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"'SyntheticChildrenFrontend::LibcxxSharedPtrSyntheticFrontEnd' cannot " | |
"'LibcxxSharedPtrSyntheticFrontEnd' cannot " |
size_t idx = ExtractIndexFromString(name.GetCString()); | ||
if (idx == UINT32_MAX) { | ||
return llvm::createStringError( | ||
"'SyntheticChildrenFrontend::LibcxxInitializerListSyntheticFrontEnd' " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"'SyntheticChildrenFrontend::LibcxxInitializerListSyntheticFrontEnd' " | |
"'LibcxxInitializerListSyntheticFrontEnd' " |
(and above too)
size_t idx = ExtractIndexFromString(name.GetCString()); | ||
if (idx == UINT32_MAX) { | ||
return llvm::createStringError( | ||
"'SyntheticChildrenFrontend::AbstractListFrontEnd' cannot find index " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets omit the SyntheticChildrenFrontend::
part everywhere
(idx < UINT32_MAX && idx >= CalculateNumChildrenIgnoringErrors())) | ||
return llvm::createStringError( | ||
"'SyntheticChildrenFrontEnd::NSDictionaryMSyntheticFrontEnd' cannot " | ||
"find index of child '%s'. (idx='%d')", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets change all the index logging to:
"find index of child '%s'. (idx='%d')", | |
"find index of child '%s'. (idx='%" PRIu32 "')", |
} else /*if (iter != m_name_toindex.end())*/ | ||
return llvm::createStringError( | ||
"'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index " | ||
"of child '%s'", | ||
name.AsCString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else /*if (iter != m_name_toindex.end())*/ | |
return llvm::createStringError( | |
"'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index " | |
"of child '%s'", | |
name.AsCString()); | |
} | |
return llvm::createStringError( | |
"'SyntheticChildrenFrontEnd::ValueObjectSynthetic' cannot find index " | |
"of child '%s'", | |
name.AsCString()); |
cc07830
to
14b5250
Compare
synthetic_children->GetIndexOfChildWithName(s_FuncPtr_name); | ||
|
||
if (!index_or_err) { | ||
LLDB_LOG_ERROR(GetLog(LLDBLog::Types), index_or_err.takeError(), "{0}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LLDB_LOG_ERROR(GetLog(LLDBLog::Types), index_or_err.takeError(), "{0}"); | |
LLDB_LOG_ERROR(GetLog(LLDBLog::DataFormatters), index_or_err.takeError(), "{0}"); |
✅ With the latest revision this PR passed the C/C++ code formatter. |
Co-authored-by: Michael Buch <[email protected]>
Co-authored-by: Michael Buch <[email protected]>
Co-authored-by: Michael Buch <[email protected]>
Co-authored-by: Michael Buch <[email protected]>
…m#136693) This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. # Tasks to do in another PR 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](llvm#136693 (comment)). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](llvm#136693 (comment)). 3. Create a new class which carries both user and internal errors. See [this comment](llvm#136693 (comment)).
…m#136693) This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. # Tasks to do in another PR 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](llvm#136693 (comment)). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](llvm#136693 (comment)). 3. Create a new class which carries both user and internal errors. See [this comment](llvm#136693 (comment)).
…m#136693) This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. # Tasks to do in another PR 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](llvm#136693 (comment)). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](llvm#136693 (comment)). 3. Create a new class which carries both user and internal errors. See [this comment](llvm#136693 (comment)).
…ected` (#136693) This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. # Tasks to do in another PR 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](llvm/llvm-project#136693 (comment)). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](llvm/llvm-project#136693 (comment)). 3. Create a new class which carries both user and internal errors. See [this comment](llvm/llvm-project#136693 (comment)).
…m#136693) This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. # Tasks to do in another PR 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](llvm#136693 (comment)). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](llvm#136693 (comment)). 3. Create a new class which carries both user and internal errors. See [this comment](llvm#136693 (comment)).
…turn std::optional (#138297) This PR is in continuation of llvm/llvm-project#136693.
…m#136693) This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](llvm#136693 (comment)). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](llvm#136693 (comment)). 3. Create a new class which carries both user and internal errors. See [this comment](llvm#136693 (comment)).
…ptional (llvm#138297) This PR is in continuation of llvm#136693.
…m#136693) This patch replaces the use of `UINT32_MAX` as the error return value of `GetIndexOfChildWithName` with `llvm::Expected`. # Tasks to do in another PR 1. Replace `CalculateNumChildrenIgnoringErrors` with `CalculateNumChildren`. See [this comment](llvm#136693 (comment)). 2. Update `lldb_private::formatters::ExtractIndexFromString` to use `llvm::Expected`. See [this comment](llvm#136693 (comment)). 3. Create a new class which carries both user and internal errors. See [this comment](llvm#136693 (comment)).
This patch replaces the use of
UINT32_MAX
as the error return value ofGetIndexOfChildWithName
withllvm::Expected
.Tasks to do in another PR
CalculateNumChildrenIgnoringErrors
withCalculateNumChildren
. See this comment.lldb_private::formatters::ExtractIndexFromString
to usellvm::Expected
. See this comment.