https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/70641
>From 7de2335efd85ae6058705a6a6cd9c5b160aef757 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Sat, 28 Oct 2023 15:24:47 +0100 Subject: [PATCH 1/2] [lldb][test] Add FindGlobalVariables tests for C++ constexpr static data members --- .../TestConstStaticIntegralMember.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py index 530191e8a37ba1b..8944044d5a265c0 100644 --- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py +++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py @@ -113,6 +113,37 @@ def test_class_with_only_const_static(self): self.expect_expr("ClassWithOnlyConstStatic::member", result_value="3") + def check_global_var(self, name: str, expect_type, expect_val): + var_list = self.target().FindGlobalVariables(name, lldb.UINT32_MAX) + self.assertEqual(len(var_list), 1) + varobj = var_list[0] + self.assertEqual(varobj.type.name, expect_type) + self.assertEqual(varobj.value, expect_val) + + # For debug-info produced by older versions of clang, inline static data members + # wouldn't get indexed into the Names accelerator table preventing LLDB from finding + # them. + @expectedFailureAll(compiler=["clang"], compiler_version=["<", "18.0"]) + @expectedFailureAll(debug_info=no_match(["dsym"])) + def test_inline_static_members(self): + self.build() + lldbutil.run_to_source_breakpoint( + self, "// break here", lldb.SBFileSpec("main.cpp") + ) + + self.check_global_var("A::int_val", "const int", "1") + self.check_global_var("A::int_val_with_address", "const int", "2") + self.check_global_var("A::bool_val", "const bool", "true") + self.check_global_var("A::enum_val", "Enum", "enum_case2") + self.check_global_var("A::enum_bool_val", "EnumBool", "enum_bool_case1") + self.check_global_var("A::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") + + self.check_global_var("ClassWithOnlyConstStatic::member", "const int", "3") + + self.check_global_var("ClassWithConstexprs::member", "const int", "2") + self.check_global_var("ClassWithConstexprs::enum_val", "Enum", "enum_case2") + self.check_global_var("ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") + # With older versions of Clang, LLDB fails to evaluate classes with only # constexpr members when dsymutil is enabled @expectedFailureAll( >From 7356debaf9d6080e35a1aa3b3562bdb990a0a33e Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Tue, 31 Oct 2023 09:03:15 +0000 Subject: [PATCH 2/2] fixup! fix format --- .../TestConstStaticIntegralMember.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py index 8944044d5a265c0..dd972ae401a6c62 100644 --- a/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py +++ b/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py @@ -142,7 +142,9 @@ def test_inline_static_members(self): self.check_global_var("ClassWithConstexprs::member", "const int", "2") self.check_global_var("ClassWithConstexprs::enum_val", "Enum", "enum_case2") - self.check_global_var("ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2") + self.check_global_var( + "ClassWithConstexprs::scoped_enum_val", "ScopedEnum", "scoped_enum_case2" + ) # With older versions of Clang, LLDB fails to evaluate classes with only # constexpr members when dsymutil is enabled _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits