[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Or rather, I didn't build with all LLVM targets.

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Apologies, I made a last-minute rebase without rebuilding. Thanks for reverting!

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread Florian Mayer via lldb-commits

fmayer wrote:

I think this broke the build completely?

```
/usr/local/google/home/fmayer/large/llvm-project/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp:771:14:
 error: no viable conversion from 'llvm::Expected' (aka 
'Expected') to 'uint32_t' (aka 'unsigned int')
uint32_t n = m_type.GetNumChildren(omit_empty_base_classes, nullptr);
 ^   ~~~
```

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl closed 
https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/84219

>From 0504cd6b50df6fafe36bade310fe1b729a3d9cea Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 7 Mar 2024 13:03:14 -0800
Subject: [PATCH] Change GetNumChildren()/CalculateNumChildren() to return
 llvm::Expected

This is an NFC change that does not yet add any error handling or
change any code to return any errors. Some select APIs may
legitimately not care about errors, so this patch also adds a
GetNumChildrenIgnoringErrors() variant to the API.

As we convert more APIs to returning llvm::Expected, we expect the
number of calls to GetNumChildrenIgnoringErrors() to dwindle.
---
 lldb/include/lldb/Core/ValueObject.h  | 11 +++-
 lldb/include/lldb/Core/ValueObjectCast.h  |  2 +-
 lldb/include/lldb/Core/ValueObjectChild.h |  2 +-
 .../lldb/Core/ValueObjectConstResult.h|  2 +-
 .../lldb/Core/ValueObjectDynamicValue.h   |  2 +-
 lldb/include/lldb/Core/ValueObjectMemory.h|  2 +-
 lldb/include/lldb/Core/ValueObjectRegister.h  |  4 +-
 .../lldb/Core/ValueObjectSyntheticFilter.h|  2 +-
 lldb/include/lldb/Core/ValueObjectVTable.h|  2 +-
 lldb/include/lldb/Core/ValueObjectVariable.h  |  2 +-
 .../lldb/DataFormatters/TypeSynthetic.h   | 20 --
 .../lldb/DataFormatters/VectorIterator.h  |  2 +-
 lldb/include/lldb/Symbol/CompilerType.h   |  5 +-
 lldb/include/lldb/Symbol/Type.h   |  2 +-
 lldb/include/lldb/Symbol/TypeSystem.h |  7 +-
 .../lldb/Target/StackFrameRecognizer.h|  3 +-
 lldb/include/lldb/Utility/Log.h   | 14 
 lldb/source/API/SBValue.cpp   |  2 +-
 lldb/source/Core/FormatEntity.cpp |  2 +-
 lldb/source/Core/IOHandlerCursesGUI.cpp   |  2 +-
 lldb/source/Core/ValueObject.cpp  | 31 ++---
 lldb/source/Core/ValueObjectCast.cpp  |  6 +-
 lldb/source/Core/ValueObjectChild.cpp |  6 +-
 lldb/source/Core/ValueObjectConstResult.cpp   |  7 +-
 lldb/source/Core/ValueObjectDynamicValue.cpp  |  7 +-
 lldb/source/Core/ValueObjectMemory.cpp| 10 ++-
 lldb/source/Core/ValueObjectRegister.cpp  | 12 ++--
 .../Core/ValueObjectSyntheticFilter.cpp   | 24 ---
 lldb/source/Core/ValueObjectVTable.cpp|  6 +-
 lldb/source/Core/ValueObjectVariable.cpp  |  7 +-
 lldb/source/DataFormatters/FormatManager.cpp  | 11 +++-
 lldb/source/DataFormatters/TypeSynthetic.cpp  | 17 -
 .../DataFormatters/ValueObjectPrinter.cpp |  2 +-
 lldb/source/DataFormatters/VectorType.cpp | 16 +++--
 .../Clang/ClangExpressionSourceCode.cpp   |  2 +-
 .../TSan/InstrumentationRuntimeTSan.cpp   |  4 +-
 .../Language/CPlusPlus/BlockPointer.cpp   |  4 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp |  8 ++-
 .../Plugins/Language/CPlusPlus/Coroutines.h   |  2 +-
 .../Language/CPlusPlus/GenericBitset.cpp  |  4 +-
 .../Language/CPlusPlus/GenericOptional.cpp|  6 +-
 .../Plugins/Language/CPlusPlus/LibCxx.cpp | 18 +++---
 .../Plugins/Language/CPlusPlus/LibCxx.h   |  8 +--
 .../Language/CPlusPlus/LibCxxAtomic.cpp   |  6 +-
 .../CPlusPlus/LibCxxInitializerList.cpp   |  6 +-
 .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 12 ++--
 .../Plugins/Language/CPlusPlus/LibCxxMap.cpp  | 14 ++--
 .../Language/CPlusPlus/LibCxxQueue.cpp|  2 +-
 .../CPlusPlus/LibCxxRangesRefView.cpp |  2 +-
 .../Plugins/Language/CPlusPlus/LibCxxSpan.cpp |  6 +-
 .../Language/CPlusPlus/LibCxxTuple.cpp|  4 +-
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp |  8 +--
 .../Language/CPlusPlus/LibCxxValarray.cpp |  6 +-
 .../Language/CPlusPlus/LibCxxVariant.cpp  |  2 +-
 .../Language/CPlusPlus/LibCxxVector.cpp   | 14 ++--
 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp  | 17 +++--
 .../Language/CPlusPlus/LibStdcppTuple.cpp |  7 +-
 .../CPlusPlus/LibStdcppUniquePointer.cpp  |  5 +-
 lldb/source/Plugins/Language/ObjC/Cocoa.cpp   |  2 +-
 lldb/source/Plugins/Language/ObjC/NSArray.cpp | 30 -
 .../Plugins/Language/ObjC/NSDictionary.cpp| 64 +--
 lldb/source/Plugins/Language/ObjC/NSError.cpp |  2 +-
 .../Plugins/Language/ObjC/NSException.cpp |  4 +-
 .../Plugins/Language/ObjC/NSIndexPath.cpp |  6 +-
 lldb/source/Plugins/Language/ObjC/NSSet.cpp   | 32 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  3 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 40 
 .../TypeSystem/Clang/TypeSystemClang.h|  7 +-
 lldb/source/Symbol/CompilerType.cpp   |  5 +-
 lldb/source/Symbol/Type.cpp   |  2 +-
 lldb/source/Symbol/Variable.cpp   |  6 +-
 lldb/source/Target/StackFrame.cpp | 19 +++---
 72 files changed, 394 insertions(+), 247 deletions(-)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index b4d2c8098edc71..e7e35e2b2bffc0 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ 

[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

LGTM.  The "IgnoringErrors" makes this construct easier to spot, and also 
should give anyone a bad feeling if they are tempted to use it...

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

@walter-erquinigo @jimingham I updated the patch to implement Jim's suggestion 
of adding an explicit `GetNumChilrdrenIgnoringErrors()` API that also ticks off 
the "big red warning flag" @JDevlieghere was pushing for.

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-08 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/84219

>From 97a80ffa93d9fd648f0aa995b51981f0ad949530 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 7 Mar 2024 13:03:14 -0800
Subject: [PATCH] Let GetNumChildren()/CalculateNumChildren() return
 llvm::Expected

This is an NFC change that does not yet add any error handling or
change any code to return any errors. Some select APIs may
legitimately not care about errors, so this patch also adds a
GetNumChildrenIgnoringErrors() variant to the API.

As we convert more APIs to returning llvm::Expected, we expect the
number of calls to GetNumChildrenIgnoringErrors() to dwindle.
---
 lldb/include/lldb/Core/ValueObject.h  | 11 +++-
 lldb/include/lldb/Core/ValueObjectCast.h  |  2 +-
 lldb/include/lldb/Core/ValueObjectChild.h |  2 +-
 .../lldb/Core/ValueObjectConstResult.h|  2 +-
 .../lldb/Core/ValueObjectDynamicValue.h   |  2 +-
 lldb/include/lldb/Core/ValueObjectMemory.h|  2 +-
 lldb/include/lldb/Core/ValueObjectRegister.h  |  4 +-
 .../lldb/Core/ValueObjectSyntheticFilter.h|  2 +-
 lldb/include/lldb/Core/ValueObjectVTable.h|  2 +-
 lldb/include/lldb/Core/ValueObjectVariable.h  |  2 +-
 .../lldb/DataFormatters/TypeSynthetic.h   | 20 --
 .../lldb/DataFormatters/VectorIterator.h  |  2 +-
 lldb/include/lldb/Symbol/CompilerType.h   |  5 +-
 lldb/include/lldb/Symbol/Type.h   |  2 +-
 lldb/include/lldb/Symbol/TypeSystem.h |  7 +-
 .../lldb/Target/StackFrameRecognizer.h|  3 +-
 lldb/include/lldb/Utility/Log.h   | 14 
 lldb/source/API/SBValue.cpp   |  2 +-
 lldb/source/Core/FormatEntity.cpp |  2 +-
 lldb/source/Core/IOHandlerCursesGUI.cpp   |  2 +-
 lldb/source/Core/ValueObject.cpp  | 31 ++---
 lldb/source/Core/ValueObjectCast.cpp  |  6 +-
 lldb/source/Core/ValueObjectChild.cpp |  6 +-
 lldb/source/Core/ValueObjectConstResult.cpp   |  7 +-
 lldb/source/Core/ValueObjectDynamicValue.cpp  |  7 +-
 lldb/source/Core/ValueObjectMemory.cpp| 10 ++-
 lldb/source/Core/ValueObjectRegister.cpp  | 12 ++--
 .../Core/ValueObjectSyntheticFilter.cpp   | 24 ---
 lldb/source/Core/ValueObjectVTable.cpp|  6 +-
 lldb/source/Core/ValueObjectVariable.cpp  |  7 +-
 lldb/source/DataFormatters/FormatManager.cpp  | 13 ++--
 lldb/source/DataFormatters/TypeSynthetic.cpp  | 17 -
 .../DataFormatters/ValueObjectPrinter.cpp |  2 +-
 lldb/source/DataFormatters/VectorType.cpp | 16 +++--
 .../Clang/ClangExpressionSourceCode.cpp   |  2 +-
 .../TSan/InstrumentationRuntimeTSan.cpp   |  4 +-
 .../Language/CPlusPlus/BlockPointer.cpp   |  4 +-
 .../Plugins/Language/CPlusPlus/Coroutines.cpp |  8 ++-
 .../Plugins/Language/CPlusPlus/Coroutines.h   |  2 +-
 .../Language/CPlusPlus/GenericBitset.cpp  |  4 +-
 .../Language/CPlusPlus/GenericOptional.cpp|  6 +-
 .../Plugins/Language/CPlusPlus/LibCxx.cpp | 18 +++---
 .../Plugins/Language/CPlusPlus/LibCxx.h   |  8 +--
 .../Language/CPlusPlus/LibCxxAtomic.cpp   |  6 +-
 .../CPlusPlus/LibCxxInitializerList.cpp   |  6 +-
 .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 12 ++--
 .../Plugins/Language/CPlusPlus/LibCxxMap.cpp  | 14 ++--
 .../Language/CPlusPlus/LibCxxQueue.cpp|  2 +-
 .../CPlusPlus/LibCxxRangesRefView.cpp |  2 +-
 .../Plugins/Language/CPlusPlus/LibCxxSpan.cpp |  6 +-
 .../Language/CPlusPlus/LibCxxTuple.cpp|  4 +-
 .../Language/CPlusPlus/LibCxxUnorderedMap.cpp |  8 +--
 .../Language/CPlusPlus/LibCxxValarray.cpp |  6 +-
 .../Language/CPlusPlus/LibCxxVariant.cpp  |  2 +-
 .../Language/CPlusPlus/LibCxxVector.cpp   | 14 ++--
 .../Plugins/Language/CPlusPlus/LibStdcpp.cpp  | 17 +++--
 .../Language/CPlusPlus/LibStdcppTuple.cpp |  7 +-
 .../CPlusPlus/LibStdcppUniquePointer.cpp  |  5 +-
 lldb/source/Plugins/Language/ObjC/Cocoa.cpp   |  2 +-
 lldb/source/Plugins/Language/ObjC/NSArray.cpp | 30 -
 .../Plugins/Language/ObjC/NSDictionary.cpp| 64 +--
 lldb/source/Plugins/Language/ObjC/NSError.cpp |  2 +-
 .../Plugins/Language/ObjC/NSException.cpp |  4 +-
 .../Plugins/Language/ObjC/NSIndexPath.cpp |  6 +-
 lldb/source/Plugins/Language/ObjC/NSSet.cpp   | 32 +-
 .../AppleObjCRuntime/AppleObjCRuntime.cpp |  3 +-
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 40 
 .../TypeSystem/Clang/TypeSystemClang.h|  7 +-
 lldb/source/Symbol/CompilerType.cpp   |  5 +-
 lldb/source/Symbol/Type.cpp   |  2 +-
 lldb/source/Symbol/Variable.cpp   |  6 +-
 lldb/source/Target/StackFrame.cpp | 19 +++---
 72 files changed, 395 insertions(+), 248 deletions(-)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index b4d2c8098edc71..e7e35e2b2bffc0 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ 

[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-07 Thread via lldb-commits

jimingham wrote:

> > I would say this differently.  Many clients of the GetNumChildren API are 
> > planning to respond the same way to an error and a number of children == 0.
> 
> I haven't done a complete audit, but my expectation for this patch is that 
> the vast majority of users of this API will want to bubble up the error. So 
> I'm seeing this as a transition state, with the goal being to convert all 
> functions that currently use the ValueOr function to also return an Expected.

Cool!  If that ends up not being the case then it would be good to have 
something that says the distinction doesn't matter, but if this construct 
vanishes, all the better!

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-07 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> I would say this differently.  Many clients of the GetNumChildren API are 
> planning to respond the same way to an error and a number of children == 0.

I haven't done a complete audit, but my expectation for this patch is that the 
vast majority of users of this API will want to bubble up the error. So I'm 
seeing this as a transition state, with the goal being to convert all functions 
that currently use the ValueOr function to also return an Expected.

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-07 Thread via lldb-commits

jimingham wrote:

I would say this differently.  Many clients of the GetNumChildren API are 
planning to respond the same way to an error and a number of children == 0.  
Having to embed this "i'm not actually checking the error, I'm just converting 
it to num-children = 0" snippet looks odd, like "Why are you bothering with 
errors when you just discard them immediately for "value is 0".

A better title for this use of GetNumChildren would be something like 
GetNumChildrenErrorsAreZero.  That has the virtue of saying what's going on 
explicitly.

Jim

> On Mar 7, 2024, at 10:45 AM, Jonas Devlieghere ***@***.***> wrote:
> 
> 
> @JDevlieghere requested changes on this pull request.
> 
> I'm worried about making it too easy to ignore errors. The whole point of the 
> llvm::Error class is that you have to check it. There might be a legitimate 
> reason you don't about the error the call site, but it should very explicit 
> and easily auditable. If none of the callers care about the error, then it 
> shouldn't be an Error/Expected in the first place. We have plenty of examples 
> of that in LLVM.
> 
> I totally understand the need for this as a transitional tool, but I want to 
> make sure nobody writes new code using this. I can see two ways to make 
> discourage that:
> 
> Mark the helper as deprecated. This might generate a lot off noise though.
> Make it really obvious in the name that this is a temporary or that we're 
> purposely dropping the error. Either something like FIX_ERROR_HANDLING or 
> LLDB_DROP_ERROR or something. Logging to the verbose log is better than 
> nothing, but it doesn't constitute error handling.
> PS: The current implementation wraps the LLDB_LOG_* which uses #line and 
> #file information. Now all those errors will get attributed to this helper 
> function.
> 
> —
> Reply to this email directly, view it on GitHub 
> ,
>  or unsubscribe 
> .
> You are receiving this because you are on a team that was mentioned.
> 



https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-07 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere requested changes to this pull request.

I'm worried about making it too easy to ignore errors. The whole point of the 
llvm::Error class is that you have to check it. There might be a legitimate 
reason you don't about the error the call site, but it should very explicit and 
easily auditable. If none of the callers care about the error, then it 
shouldn't be an Error/Expected in the first place. We have plenty of examples 
of that in LLVM. 

I totally understand the need for this as a transitional tool, but I want to 
make sure nobody writes new code using this. I can see two ways to make 
discourage that:

 - Mark the helper as deprecated. This might generate a lot off noise though. 
 - Make it really obvious in the name that this is a temporary or that we're 
purposely dropping the error. Either something like `FIX_ERROR_HANDLING` or 
`LLDB_DROP_ERROR` or something. Logging to the verbose log is better than 
nothing, but it doesn't constitute error handling. 

PS: The current implementation wraps the `LLDB_LOG_*` which uses #line and 
#file information. Now all those errors will get attributed to this helper 
function.

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-06 Thread Adrian Prantl via lldb-commits


@@ -451,8 +451,13 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject 
) {
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
+  auto num_children = valobj.GetNumChildren();
+  if (!num_children) {
+llvm::consumeError(num_children.takeError());

adrian-prantl wrote:

Done!

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-06 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

@walter-erquinigo I was wondering if it would make sense to create a 
DropAndLogError() wrapper for all these places. The main problem would be that 
we end up calling these functions dozens of times over and over so we'd be 
spamming the logs quite a bit. But maybe doing a verbose log would be 
appropriate. I'll modify the patch accordingly.

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-06 Thread Walter Erquinigo via lldb-commits


@@ -1397,7 +1398,9 @@ ValueObjectSP GetValueForOffset(StackFrame , 
ValueObjectSP ,
 return parent;
   }
 
-  for (int ci = 0, ce = parent->GetNumChildren(); ci != ce; ++ci) {
+  for (int ci = 0, ce = llvm::expectedToStdOptional(parent->GetNumChildren())

walter-erquinigo wrote:

I'm afraid that calls to `expectedToStdOptional` will just silence important 
warnings.

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-06 Thread Walter Erquinigo via lldb-commits


@@ -451,8 +451,13 @@ bool FormatManager::ShouldPrintAsOneLiner(ValueObject 
) {
   if (valobj.GetSummaryFormat().get() != nullptr)
 return valobj.GetSummaryFormat()->IsOneLiner();
 
+  auto num_children = valobj.GetNumChildren();
+  if (!num_children) {
+llvm::consumeError(num_children.takeError());

walter-erquinigo wrote:

could you log this some channel instead of consuming the error? That would 
still be NFC and would fit well within this PR

https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-06 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 21be2fbd17f9ff6f3f04e0ababc91c9cdd5aed85 
d3112e0cd5932e1e1413ed22f71adec70bc81bbf -- 
lldb/include/lldb/Core/ValueObject.h lldb/include/lldb/Core/ValueObjectCast.h 
lldb/include/lldb/Core/ValueObjectChild.h 
lldb/include/lldb/Core/ValueObjectConstResult.h 
lldb/include/lldb/Core/ValueObjectDynamicValue.h 
lldb/include/lldb/Core/ValueObjectMemory.h 
lldb/include/lldb/Core/ValueObjectRegister.h 
lldb/include/lldb/Core/ValueObjectSyntheticFilter.h 
lldb/include/lldb/Core/ValueObjectVTable.h 
lldb/include/lldb/Core/ValueObjectVariable.h 
lldb/include/lldb/DataFormatters/TypeSynthetic.h 
lldb/include/lldb/DataFormatters/VectorIterator.h 
lldb/include/lldb/Symbol/CompilerType.h lldb/include/lldb/Symbol/Type.h 
lldb/include/lldb/Symbol/TypeSystem.h 
lldb/include/lldb/Target/StackFrameRecognizer.h lldb/source/API/SBValue.cpp 
lldb/source/Core/FormatEntity.cpp lldb/source/Core/IOHandlerCursesGUI.cpp 
lldb/source/Core/ValueObject.cpp lldb/source/Core/ValueObjectCast.cpp 
lldb/source/Core/ValueObjectChild.cpp 
lldb/source/Core/ValueObjectConstResult.cpp 
lldb/source/Core/ValueObjectDynamicValue.cpp 
lldb/source/Core/ValueObjectMemory.cpp lldb/source/Core/ValueObjectRegister.cpp 
lldb/source/Core/ValueObjectSyntheticFilter.cpp 
lldb/source/Core/ValueObjectVTable.cpp lldb/source/Core/ValueObjectVariable.cpp 
lldb/source/DataFormatters/FormatManager.cpp 
lldb/source/DataFormatters/TypeSynthetic.cpp 
lldb/source/DataFormatters/ValueObjectPrinter.cpp 
lldb/source/DataFormatters/VectorType.cpp 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp 
lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp 
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.cpp 
lldb/source/Plugins/Language/CPlusPlus/Coroutines.h 
lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp 
lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.h 
lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxQueue.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxSpan.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxValarray.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxVariant.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp 
lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
lldb/source/Plugins/Language/ObjC/NSArray.cpp 
lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
lldb/source/Plugins/Language/ObjC/NSError.cpp 
lldb/source/Plugins/Language/ObjC/NSException.cpp 
lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp 
lldb/source/Plugins/Language/ObjC/NSSet.cpp 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
lldb/source/Symbol/CompilerType.cpp lldb/source/Symbol/Type.cpp 
lldb/source/Symbol/Variable.cpp lldb/source/Target/StackFrame.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp 
b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 258c3debf1..749aa6f112 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -684,9 +684,8 @@ 
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
 }
 
 template 
-lldb::ValueObjectSP
-lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::
-  GetChildAtIndex(uint32_t idx) {
+lldb::ValueObjectSP lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<
+D32, D64, Inline>::GetChildAtIndex(uint32_t idx) {
   if (idx >= llvm::expectedToStdOptional(CalculateNumChildren()).value_or(0))
 return lldb::ValueObjectSP();
   lldb::addr_t object_at_idx;
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index 726063c54d..69eb253505 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -262,9 +262,9 @@ namespace Foundation1100 {
 NSDictionaryMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
  

[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-06 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl edited 
https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Change GetNumChildren()/CalculateNumChildren() methods return llvm::Expected (PR #84219)

2024-03-06 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl edited 
https://github.com/llvm/llvm-project/pull/84219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits