llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Vlad Serebrennikov (Endilll) <details> <summary>Changes</summary> This patch adds the value to enumerator dump, e.g. `Enumerator` now dumped as `Enumerator(0)`. There are not-so-uncommon cases when value of enumerator is no less important than its name. One example can be found in https://github.com/llvm/llvm-project/blob/4aae5387a874a55ee491f5dc23ce0506c5cdc678/clang/include/clang/AST/DeclarationName.h#L183 Another one, number of bits to shift, can be found in https://github.com/llvm/llvm-project/blob/4aae5387a874a55ee491f5dc23ce0506c5cdc678/llvm/include/llvm/ADT/PointerIntPair.h#L181 --- Full diff: https://github.com/llvm/llvm-project/pull/69815.diff 6 Files Affected: - (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+1-1) - (modified) lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py (+1-1) - (modified) lldb/test/API/lang/c/enum_types/TestEnumTypes.py (+5-5) - (modified) lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py (+10-10) - (modified) lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py (+3-3) - (modified) lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py (+1-1) ``````````diff diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index f1353db2631ddc6..b1ec1cf9a322907 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -8550,7 +8550,7 @@ static bool DumpEnumValue(const clang::QualType &qual_type, Stream &s, ++num_enumerators; if (val == enum_svalue) { // Found an exact match, that's all we need to do. - s.PutCString(enumerator->getNameAsString()); + s.Printf("%s(%" PRIi64 ")", enumerator->getNameAsString().c_str(), enum_svalue); return true; } } diff --git a/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py b/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py index 923f021d53399cb..00610a29353423f 100644 --- a/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py +++ b/lldb/test/API/commands/expression/cast_int_to_anonymous_enum/TestCastIntToAnonymousEnum.py @@ -18,4 +18,4 @@ def test_cast_int_to_anonymous_enum(self): self, "// break here", lldb.SBFileSpec("main.cpp", False) ) - self.expect_expr("(flow_e)0", result_type="flow_e", result_value="A") + self.expect_expr("(flow_e)0", result_type="flow_e", result_value="A(0)") diff --git a/lldb/test/API/lang/c/enum_types/TestEnumTypes.py b/lldb/test/API/lang/c/enum_types/TestEnumTypes.py index 33a846c50d7def3..e69cefee2540d47 100644 --- a/lldb/test/API/lang/c/enum_types/TestEnumTypes.py +++ b/lldb/test/API/lang/c/enum_types/TestEnumTypes.py @@ -22,12 +22,12 @@ def test_command_line(self): self, "// Breakpoint for bitfield", lldb.SBFileSpec("main.c") ) - self.expect("fr var a", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = A$"]) - self.expect("fr var b", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = B$"]) - self.expect("fr var c", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = C$"]) - self.expect("fr var ab", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = AB$"]) + self.expect("fr var a", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = A\\(1\\)$"]) + self.expect("fr var b", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = B\\(2\\)$"]) + self.expect("fr var c", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = C\\(4\\)$"]) + self.expect("fr var ab", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = AB\\(3\\)$"]) self.expect("fr var ac", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = A | C$"]) - self.expect("fr var all", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = ALL$"]) + self.expect("fr var all", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = ALL\\(7\\)$"]) # Test that an enum that doesn't match the heuristic we use in # TypeSystemClang::DumpEnumValue, gets printed as a raw integer. self.expect("fr var omega", DATA_TYPES_DISPLAYED_CORRECTLY, patterns=[" = 7$"]) 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..80e81c0df8a5bfd 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 @@ -57,12 +57,12 @@ def test(self): self.expect_expr("A::wchar_min == wchar_min", result_value="true") # Test an unscoped enum. - self.expect_expr("A::enum_val", result_value="enum_case2") + self.expect_expr("A::enum_val", result_value="enum_case2(2)") # Test an unscoped enum with bool as the underlying type. - self.expect_expr("A::enum_bool_val", result_value="enum_bool_case1") + self.expect_expr("A::enum_bool_val", result_value="enum_bool_case1(0)") # Test a scoped enum. - self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2") + self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2(2)") # Test an scoped enum with a value that isn't an enumerator. self.expect_expr( "A::not_enumerator_scoped_enum_val", result_value="scoped_enum_case1 | 0x4" @@ -74,9 +74,9 @@ def test(self): ) # Test an enum with fixed underlying type. - self.expect_expr("A::scoped_char_enum_val", result_value="case2") - self.expect_expr("A::scoped_ll_enum_val_neg", result_value="case0") - self.expect_expr("A::scoped_ll_enum_val", result_value="case2") + self.expect_expr("A::scoped_char_enum_val", result_value="case2(2)") + self.expect_expr("A::scoped_ll_enum_val_neg", result_value="case0(-9223372036854775808)") + self.expect_expr("A::scoped_ll_enum_val", result_value="case2(9223372036854775807)") # Test taking address. if lldbplatformutil.getPlatform() == "windows": @@ -126,15 +126,15 @@ def test_class_with_only_constexpr_static(self): # Test `constexpr static`. self.expect_expr("ClassWithConstexprs::member", result_value="2") - self.expect_expr("ClassWithConstexprs::enum_val", result_value="enum_case2") + self.expect_expr("ClassWithConstexprs::enum_val", result_value="enum_case2(2)") self.expect_expr( - "ClassWithConstexprs::scoped_enum_val", result_value="scoped_enum_case2" + "ClassWithConstexprs::scoped_enum_val", result_value="scoped_enum_case2(2)" ) # Test an aliased enum with fixed underlying type. self.expect_expr( - "ClassWithEnumAlias::enum_alias", result_value="scoped_enum_case2" + "ClassWithEnumAlias::enum_alias", result_value="scoped_enum_case2(2)" ) self.expect_expr( - "ClassWithEnumAlias::enum_alias_alias", result_value="scoped_enum_case1" + "ClassWithEnumAlias::enum_alias_alias", result_value="scoped_enum_case1(1)" ) diff --git a/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py b/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py index 09b8967a443b39d..bb8b145d672b7ee 100644 --- a/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py +++ b/lldb/test/API/lang/cpp/enum_types/TestCPP11EnumTypes.py @@ -23,9 +23,9 @@ def check_enum(self, suffix): substrs=["Case1", "Case2", "Case3"], ) # Test each case in the enum. - self.expect_expr("var1_" + suffix, result_type=enum_name, result_value="Case1") - self.expect_expr("var2_" + suffix, result_type=enum_name, result_value="Case2") - self.expect_expr("var3_" + suffix, result_type=enum_name, result_value="Case3") + self.expect("expr var1_" + suffix, patterns=[f"\\({enum_name}\\) \\$\\d+ = Case1\\(-?\\d+\\)"]) + self.expect("expr var2_" + suffix, patterns=[f"\\({enum_name}\\) \\$\\d+ = Case2\\(-?\\d+\\)"]) + self.expect("expr var3_" + suffix, patterns=[f"\\({enum_name}\\) \\$\\d+ = Case3\\(-?\\d+\\)"]) if unsigned: self.expect_expr( diff --git a/lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py b/lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py index 46f96d89221d596..ab95e63422c3725 100644 --- a/lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py +++ b/lldb/test/API/lang/rust/enum-structs/TestRustEnumStructs.py @@ -32,7 +32,7 @@ def test_clike_enums_are_represented_correctly(self): self.target().FindFirstGlobalVariable("CLIKE_U32_B").GetValue(), ] self.assertEqual( - all_values, ["A", "B", "VariantA", "VariantC", "VariantA", "VariantB"] + all_values, ["A(2)", "B(10)", "VariantA(0)", "VariantC(2)", "VariantA(1)", "VariantB(2)"] ) def test_enum_with_tuples_has_all_variants(self): `````````` </details> https://github.com/llvm/llvm-project/pull/69815 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits