Adds test that checks whether LLDB correctly infers the alignment of packed structures. Specifically, the `InferAlignment` code-path of the `ItaniumRecordLayoutBuilder` where it assumes that overlapping field offsets imply a packed structure and thus sets alignment to `1`. See discussion in https://github.com/llvm/llvm-project/pull/93809. While here, also added a test-case where we check alignment of a class whose base has an explicit `DW_AT_alignment (those don't get transitively propagated in DWARF, but don't seem like a problem for LLDB). Lastly, also added an XFAIL-ed tests where the aforementioned `InferAlignment` kicks in for overlapping fields (but in this case incorrectly since the structure isn't actually packed).
20 lines
666 B
Python
20 lines
666 B
Python
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class TestCase(TestBase):
|
|
@no_debug_info_test
|
|
def test(self):
|
|
self.build()
|
|
self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
|
|
|
|
# The offset of f2 should be 8 because of `alignas(8)`.
|
|
self.expect_expr("(intptr_t)&d3g.f2 - (intptr_t)&d3g", result_value="8")
|
|
|
|
# Verify specified class alignments.
|
|
self.expect_expr("alignof(B2)", result_value="8")
|
|
self.expect_expr("alignof(EmptyClassAlign8)", result_value="8")
|
|
self.expect_expr("alignof(Derived)", result_value="8")
|