Skip to content

Commit 9dcaca7

Browse files
committed
[lldb][test] TestConstStaticIntegralMember.py: fix for clang-{9,11,13}
**Summary** The public lldb matrix bot is failing for tests compiled with clang-9, clang-11, clang-13. This patch addresses these failures by evaluating the enum case that doesn't cause malformed DWARF in older version of clang. There was no particular reason we had to use `true` enum case to reproduce the bug in #58383, so simply switch to use `false` to get all bots passing again. **Details** In older versions of clang, the following snippet: ``` enum EnumBool : bool { enum_bool_case1 = false, enum_bool_case2 = true, }; struct A { const static EnumBool enum_bool_val = enum_bool_case2; }; ``` …results in following DWARF: ``` 0x00000052: DW_TAG_structure_type DW_AT_calling_convention (DW_CC_pass_by_value) DW_AT_name ("A") DW_AT_byte_size (0x01) DW_AT_decl_file ("/Users/michaelbuch/Git/llvm-project/lldb/test/API/lang/cpp/const_static_integral_member/repro.cpp") DW_AT_decl_line (6) 0x0000005b: DW_TAG_member DW_AT_name ("enum_bool_val") DW_AT_type (0x0000000000000068 "const EnumBool") DW_AT_decl_file ("/Users/michaelbuch/Git/llvm-project/lldb/test/API/lang/cpp/const_static_integral_member/repro.cpp") DW_AT_decl_line (7) DW_AT_external (true) DW_AT_declaration (true) DW_AT_const_value (-1) ``` Note the `DW_AT_const_value == -1` When evaluating `A::enum_bool_val` in the lldb we get: ``` (lldb) p A::enum_bool_val error: expression failed to parse: error: Couldn't lookup symbols: __ZN1A13enum_bool_valE ``` Enabling the DWARF logs we see: ``` (arm64) clang-13.out: DWARFASTParserClang::ParseTypeFromDWARF (die = 0x00000068, decl_ctx = 0x136ac1e30 (die 0x0000000b)) DW_TAG_const_type name = '(null)') Failed to add const value to variable A::enum_bool_val: Can't store unsigned value 18446744073709551615 in integer with 1 bits. ``` This occurs because a boolean enum is considered an unsigned integer type, but we try to initialize it with a `-1`. **Testing** - Confirmed locally that top-of-tree lldb correctly evaluates the previously failing expression when the test program is compiled with clang-13 Differential Revision: https://reviews.llvm.org/D137793
1 parent 316e259 commit 9dcaca7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test(self):
5858
# Test an unscoped enum.
5959
self.expect_expr("A::enum_val", result_value="enum_case2")
6060
# Test an unscoped enum with bool as the underlying type.
61-
self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
61+
self.expect_expr("A::enum_bool_val", result_value="enum_bool_case1")
6262

6363
# Test a scoped enum.
6464
self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")

lldb/test/API/lang/cpp/const_static_integral_member/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ struct A {
5656
const static auto wchar_min = std::numeric_limits<wchar_t>::min();
5757

5858
const static Enum enum_val = enum_case2;
59-
const static EnumBool enum_bool_val = enum_bool_case2;
59+
const static EnumBool enum_bool_val = enum_bool_case1;
6060
const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
6161
const static ScopedEnum not_enumerator_scoped_enum_val = static_cast<ScopedEnum>(5);
6262
const static ScopedEnum not_enumerator_scoped_enum_val_2 =

0 commit comments

Comments
 (0)