xref: /llvm-project/lldb/test/API/commands/expression/bitfield_enums/TestBitfieldEnums.py (revision c471d3650aa3c6c1ddab64c029b7b89b12d18938)
1"""
2Test that the expression parser accounts for the underlying type of bitfield
3enums when looking for matching values.
4"""
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class TestBitfieldEnum(TestBase):
13    # Prior to clang-19, clang's DWARF v2 is missing missing DW_AT_type which
14    # causes unsigned_max to appear as -1 instead of the "max" enumerator, whose
15    # value is 3. From 19 onward, DW_AT_type is added as long as strict DWARF
16    # is not enabled.
17    @skipIf(dwarf_version=["<", "3"], compiler="clang", compiler_version=["<", "19.0"])
18    def test_bitfield_enums(self):
19        self.build()
20
21        lldbutil.run_to_source_breakpoint(
22            self, "// break here", lldb.SBFileSpec("main.cpp", False)
23        )
24
25        self.expect_expr(
26            "bfs",
27            result_type="BitfieldStruct",
28            result_children=[
29                ValueCheck(name="signed_min", value="min"),
30                ValueCheck(name="signed_other", value="-1"),
31                ValueCheck(name="signed_max", value="max"),
32                ValueCheck(name="unsigned_min", value="min"),
33                ValueCheck(name="unsigned_other", value="1"),
34                ValueCheck(name="unsigned_max", value="max"),
35            ],
36        )
37