This revision was automatically updated to reflect the committed changes.
Closed by commit rG704001e90b3d: [lldb] Add SBType::IsAggregateType (authored
by kastiglione).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121252/new/
https://reviews.llvm.org/D121252
Files:
lldb/bindings/interface/SBType.i
lldb/include/lldb/API/SBType.h
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBType.cpp
lldb/test/API/python_api/type/TestTypeList.py
Index: lldb/test/API/python_api/type/TestTypeList.py
===================================================================
--- lldb/test/API/python_api/type/TestTypeList.py
+++ lldb/test/API/python_api/type/TestTypeList.py
@@ -66,6 +66,7 @@
self.assertTrue(type)
self.DebugSBType(type)
self.assertFalse(type.IsAnonymousType(), "Task is not anonymous")
+ self.assertTrue(type.IsAggregateType(), "Task is aggregate")
for field in type.fields:
if field.name == "type":
for enum_member in field.type.enum_members:
@@ -75,10 +76,12 @@
self.assertFalse(
field.type.IsAnonymousType(),
"my_type_is_nameless is not an anonymous type")
+ self.assertTrue(field.type.IsAggregateType())
elif field.name == "my_type_is_named":
self.assertFalse(
field.type.IsAnonymousType(),
"my_type_is_named has a named type")
+ self.assertTrue(field.type.IsAggregateType())
elif field.name == None:
self.assertTrue(
field.type.IsAnonymousType(),
@@ -111,6 +114,7 @@
task_head_type = task_head.GetType()
self.DebugSBType(task_head_type)
self.assertTrue(task_head_type.IsPointerType())
+ self.assertFalse(task_head_type.IsAggregateType())
self.assertEqual(task_head_type, task_pointer_type)
@@ -125,6 +129,7 @@
self.DebugSBValue(id)
id_type = id.GetType()
self.DebugSBType(id_type)
+ self.assertFalse(id_type.IsAggregateType())
# SBType.GetBasicType() takes an enum 'BasicType'
# (lldb-enumerations.h).
@@ -138,6 +143,7 @@
myint_arr_type = myint_arr.GetType()
self.DebugSBType(myint_arr_type)
self.assertTrue(myint_arr_type.IsArrayType())
+ self.assertTrue(myint_arr_type.IsAggregateType())
myint_arr_element_type = myint_arr_type.GetArrayElementType()
self.DebugSBType(myint_arr_element_type)
myint_type = target.FindFirstType('myint')
@@ -150,11 +156,13 @@
self.assertTrue(enum_type)
self.DebugSBType(enum_type)
self.assertFalse(enum_type.IsScopedEnumerationType())
+ self.assertFalse(enum_type.IsAggregateType())
scoped_enum_type = target.FindFirstType('ScopedEnumType')
self.assertTrue(scoped_enum_type)
self.DebugSBType(scoped_enum_type)
self.assertTrue(scoped_enum_type.IsScopedEnumerationType())
+ self.assertFalse(scoped_enum_type.IsAggregateType())
int_scoped_enum_type = scoped_enum_type.GetEnumerationIntegerType()
self.assertTrue(int_scoped_enum_type)
self.DebugSBType(int_scoped_enum_type)
Index: lldb/source/API/SBType.cpp
===================================================================
--- lldb/source/API/SBType.cpp
+++ lldb/source/API/SBType.cpp
@@ -273,6 +273,14 @@
return m_opaque_sp->GetCompilerType(true).IsScopedEnumerationType();
}
+bool SBType::IsAggregateType() {
+ LLDB_INSTRUMENT_VA(this);
+
+ if (!IsValid())
+ return false;
+ return m_opaque_sp->GetCompilerType(true).IsAggregateType();
+}
+
lldb::SBType SBType::GetFunctionReturnType() {
LLDB_INSTRUMENT_VA(this);
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2541,6 +2541,8 @@
err.write(type.GetName() + ":\n")
err.write('\t' + "ByteSize -> " +
str(type.GetByteSize()) + '\n')
+ err.write('\t' + "IsAggregateType -> " +
+ str(type.IsAggregateType()) + '\n')
err.write('\t' + "IsPointerType -> " +
str(type.IsPointerType()) + '\n')
err.write('\t' + "IsReferenceType -> " +
Index: lldb/include/lldb/API/SBType.h
===================================================================
--- lldb/include/lldb/API/SBType.h
+++ lldb/include/lldb/API/SBType.h
@@ -133,6 +133,8 @@
bool IsScopedEnumerationType();
+ bool IsAggregateType();
+
lldb::SBType GetPointerType();
lldb::SBType GetPointeeType();
Index: lldb/bindings/interface/SBType.i
===================================================================
--- lldb/bindings/interface/SBType.i
+++ lldb/bindings/interface/SBType.i
@@ -354,6 +354,18 @@
bool
IsScopedEnumerationType ();
+ %feature("docstring",
+ "Returns true if this type is an aggregate type.
+
+ Language-specific behaviour:
+
+ * C: Returns true for struct values, arrays, and vectors.
+ * C++: Same a C. Also includes class instances.
+ * Objective-C: Same as C. Also includes class instances.
+ ") IsAggregateType;
+ bool
+ IsAggregateType ();
+
%feature("docstring",
"Returns a type that represents a pointer to this type.
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits