From 1370a1cb5b97ecfc4fd2cb550159db9c9ebd3a68 Mon Sep 17 00:00:00 2001 From: Med Ismail Bennani Date: Mon, 22 May 2023 13:52:09 -0700 Subject: [lldb] Add support for negative integer to {SB,}StructuredData This patch refactors the `StructuredData::Integer` class to make it templated, makes it private and adds 2 public specialization for both `int64_t` & `uint64_t` with a public type aliases, respectively `SignedInteger` & `UnsignedInteger`. It adds new getter for signed and unsigned interger values to the `StructuredData::Object` base class and changes the implementation of `StructuredData::Array::GetItemAtIndexAsInteger` and `StructuredData::Dictionary::GetValueForKeyAsInteger` to support signed and unsigned integers. This patch also adds 2 new `Get{Signed,Unsigned}IntegerValue` to the `SBStructuredData` class and marks `GetIntegerValue` as deprecated. Finally, this patch audits all the caller of `StructuredData::Integer` or `StructuredData::GetIntegerValue` to use the proper type as well the various tests that uses `SBStructuredData.GetIntegerValue`. rdar://105575764 Differential Revision: https://reviews.llvm.org/D150485 Signed-off-by: Med Ismail Bennani --- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h') diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h index 33092209..61ec4307 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h @@ -354,7 +354,7 @@ public: llvm::Expected AsLongLong() const; - llvm::Expected AsUnsignedLongLong() const; + llvm::Expected AsUnsignedLongLong() const; // wraps on overflow, instead of raising an error. llvm::Expected AsModuloUnsignedLongLong() const; @@ -480,6 +480,10 @@ public: void SetInteger(int64_t value); StructuredData::IntegerSP CreateStructuredInteger() const; + + StructuredData::UnsignedIntegerSP CreateStructuredUnsignedInteger() const; + + StructuredData::SignedIntegerSP CreateStructuredSignedInteger() const; }; class PythonBoolean : public TypedPythonObject { -- cgit v1.1