[Lldb-commits] [lldb] 9dcaca7 - [lldb][test] TestConstStaticIntegralMember.py: fix for clang-{9, 11, 13}
Michael Buch via lldb-commits
lldb-commits at lists.llvm.org
Thu Nov 10 14:09:36 PST 2022
Author: Michael Buch
Date: 2022-11-10T14:09:10-08:00
New Revision: 9dcaca706841fa38683eee341f24aafb58e6e3e9
URL: https://github.com/llvm/llvm-project/commit/9dcaca706841fa38683eee341f24aafb58e6e3e9
DIFF: https://github.com/llvm/llvm-project/commit/9dcaca706841fa38683eee341f24aafb58e6e3e9.diff
LOG: [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
Added:
Modified:
lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py
lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
Removed:
################################################################################
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 7fccbf8c43f5a..c490a073cfe8c 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
@@ -58,7 +58,7 @@ def test(self):
# Test an unscoped enum.
self.expect_expr("A::enum_val", result_value="enum_case2")
# Test an unscoped enum with bool as the underlying type.
- self.expect_expr("A::enum_bool_val", result_value="enum_bool_case2")
+ self.expect_expr("A::enum_bool_val", result_value="enum_bool_case1")
# Test a scoped enum.
self.expect_expr("A::scoped_enum_val", result_value="scoped_enum_case2")
diff --git a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
index 4128a4d050234..4275f471df6ae 100644
--- a/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
+++ b/lldb/test/API/lang/cpp/const_static_integral_member/main.cpp
@@ -56,7 +56,7 @@ struct A {
const static auto wchar_min = std::numeric_limits<wchar_t>::min();
const static Enum enum_val = enum_case2;
- const static EnumBool enum_bool_val = enum_bool_case2;
+ const static EnumBool enum_bool_val = enum_bool_case1;
const static ScopedEnum scoped_enum_val = ScopedEnum::scoped_enum_case2;
const static ScopedEnum not_enumerator_scoped_enum_val = static_cast<ScopedEnum>(5);
const static ScopedEnum not_enumerator_scoped_enum_val_2 =
More information about the lldb-commits
mailing list