diff options
| author | Pavel Labath <pavel@labath.sk> | 2024-05-06 10:06:51 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-06 10:06:51 +0200 |
| commit | 30367cb5982dfdab2655401f020711311e7d78b9 (patch) | |
| tree | 38954421ff3b0a15638020eaa48d5254a395d9e9 /lldb/test/API/python_api | |
| parent | eb75af223fb07d83808bd40ffde942435e9779d6 (diff) | |
| download | llvm-30367cb5982dfdab2655401f020711311e7d78b9.zip llvm-30367cb5982dfdab2655401f020711311e7d78b9.tar.gz llvm-30367cb5982dfdab2655401f020711311e7d78b9.tar.bz2 | |
[lldb] Add SBType::GetByteAlign (#90960)
lldb already mostly(*) tracks this information. This just makes it
available to the SB users.
(*) It does not do that for typedefs right now see llvm.org/pr90958
Diffstat (limited to 'lldb/test/API/python_api')
| -rw-r--r-- | lldb/test/API/python_api/type/TestTypeList.py | 21 | ||||
| -rw-r--r-- | lldb/test/API/python_api/type/main.cpp | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lldb/test/API/python_api/type/TestTypeList.py b/lldb/test/API/python_api/type/TestTypeList.py index 17e27b6..0498396 100644 --- a/lldb/test/API/python_api/type/TestTypeList.py +++ b/lldb/test/API/python_api/type/TestTypeList.py @@ -272,3 +272,24 @@ class TypeAndTypeListTestCase(TestBase): self.assertTrue(int_enum_uchar) self.DebugSBType(int_enum_uchar) self.assertEqual(int_enum_uchar.GetName(), "unsigned char") + + def test_GetByteAlign(self): + """Exercise SBType::GetByteAlign""" + self.build() + spec = lldb.SBModuleSpec() + spec.SetFileSpec(lldb.SBFileSpec(self.getBuildArtifact())) + module = lldb.SBModule(spec) + self.assertTrue(module) + + # Invalid types should not crash. + self.assertEqual(lldb.SBType().GetByteAlign(), 0) + + # Try a type with natural alignment. + void_ptr = module.GetBasicType(lldb.eBasicTypeVoid).GetPointerType() + self.assertTrue(void_ptr) + # Not exactly guaranteed by the spec, but should be true everywhere we + # care about. + self.assertEqual(void_ptr.GetByteSize(), void_ptr.GetByteAlign()) + + # And an over-aligned type. + self.assertEqual(module.FindFirstType("OverAlignedStruct").GetByteAlign(), 128) diff --git a/lldb/test/API/python_api/type/main.cpp b/lldb/test/API/python_api/type/main.cpp index 7384a3d..986ed30 100644 --- a/lldb/test/API/python_api/type/main.cpp +++ b/lldb/test/API/python_api/type/main.cpp @@ -50,6 +50,9 @@ enum EnumType {}; enum class ScopedEnumType {}; enum class EnumUChar : unsigned char {}; +struct alignas(128) OverAlignedStruct {}; +OverAlignedStruct over_aligned_struct; + int main (int argc, char const *argv[]) { Task *task_head = new Task(-1, NULL); |
