Author: Michael Buch Date: 2024-09-16T12:05:00+01:00 New Revision: 9548dbedbc1b2bfb130c91df54e8007acb81e1b0
URL: https://github.com/llvm/llvm-project/commit/9548dbedbc1b2bfb130c91df54e8007acb81e1b0 DIFF: https://github.com/llvm/llvm-project/commit/9548dbedbc1b2bfb130c91df54e8007acb81e1b0.diff LOG: [lldb][test] Add TestNoUniqueAddress.py Tests that run expressions on record types with `[[no_unique_address]]` fields. Added: lldb/test/API/lang/cpp/no_unique_address/Makefile lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py lldb/test/API/lang/cpp/no_unique_address/main.cpp Modified: Removed: ################################################################################ diff --git a/lldb/test/API/lang/cpp/no_unique_address/Makefile b/lldb/test/API/lang/cpp/no_unique_address/Makefile new file mode 100644 index 00000000000000..99998b20bcb050 --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py b/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py new file mode 100644 index 00000000000000..d16aaa14153fd7 --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py @@ -0,0 +1,67 @@ +""" +Test that LLDB correctly handles fields +marked with [[no_unique_address]]. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class NoUniqueAddressTestCase(TestBase): + def test(self): + self.build() + lldbutil.run_to_source_breakpoint( + self, "return 0", lldb.SBFileSpec("main.cpp", False) + ) + + # Qualified/unqualified lookup to templates in namespace + self.expect_expr( + "b1", + result_type="basic::Foo", + result_children=[ValueCheck(name="a", type="Empty")], + ) + + self.expect_expr( + "b2", + result_type="bases::Foo", + result_children=[ + ValueCheck( + type="bases::B", children=[ValueCheck(name="x", type="Empty")] + ), + ValueCheck( + type="bases::A", + children=[ + ValueCheck(name="c", type="long", value="1"), + ValueCheck(name="d", type="long", value="2"), + ], + ), + ValueCheck( + type="bases::C", children=[ValueCheck(name="x", type="Empty")] + ), + ], + ) + self.expect_expr( + "b3", + result_type="bases::Bar", + result_children=[ + ValueCheck( + type="bases::B", children=[ValueCheck(name="x", type="Empty")] + ), + ValueCheck( + type="bases::C", children=[ValueCheck(name="x", type="Empty")] + ), + ValueCheck( + type="bases::A", + children=[ + ValueCheck(name="c", type="long", value="5"), + ValueCheck(name="d", type="long", value="6"), + ], + ), + ], + ) + + self.expect("frame var b1") + self.expect("frame var b2") + self.expect("frame var b3") diff --git a/lldb/test/API/lang/cpp/no_unique_address/main.cpp b/lldb/test/API/lang/cpp/no_unique_address/main.cpp new file mode 100644 index 00000000000000..424fa90859ceaa --- /dev/null +++ b/lldb/test/API/lang/cpp/no_unique_address/main.cpp @@ -0,0 +1,35 @@ +struct Empty {}; + +namespace basic { +struct Foo { + [[no_unique_address]] Empty a; +}; +} // namespace basic + +namespace bases { +struct A { + long c, d; +}; + +struct B { + [[no_unique_address]] Empty x; +}; + +struct C { + [[no_unique_address]] Empty x; +}; + +struct Foo : B, A, C {}; +struct Bar : B, C, A {}; +} // namespace bases + +int main() { + basic::Foo b1; + bases::Foo b2; + bases::Bar b3; + b2.c = 1; + b2.d = 2; + b3.c = 5; + b3.d = 6; + return 0; +} _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits