Skip to content

Commit be3eb24

Browse files
committed
[lldb][test] Fix libstdc++ std::variant formatter for empty variant
Instead of using the byte-size to make a guess at what the `std::variant_npos` value is, just look it up in debug-info. Unblocks llvm#147253
1 parent 1c8283a commit be3eb24

File tree

3 files changed

+5
-14
lines changed

3 files changed

+5
-14
lines changed

lldb/examples/synthetic/gnu_libstdcpp.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -889,17 +889,12 @@ def VariantSummaryProvider(valobj, dict):
889889
if not (index_obj and index_obj.IsValid() and data_obj and data_obj.IsValid()):
890890
return "<Can't find _M_index or _M_u>"
891891

892-
def get_variant_npos_value(index_byte_size):
893-
if index_byte_size == 1:
894-
return 0xFF
895-
elif index_byte_size == 2:
896-
return 0xFFFF
897-
else:
898-
return 0xFFFFFFFF
892+
npos = valobj.GetTarget().FindFirstGlobalVariable("std::variant_npos")
893+
if not npos:
894+
return "<Can't find std::variant_npos sentinel>"
899895

900-
npos_value = get_variant_npos_value(index_obj.GetByteSize())
901896
index = index_obj.GetValueAsUnsigned(0)
902-
if index == npos_value:
897+
if index == npos.GetValueAsUnsigned(0):
903898
return " No Value"
904899

905900
# Strip references and typedefs.

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Test lldb data formatter for LibStdC++ std::variant.
33
"""
44

5-
65
import lldb
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
@@ -62,17 +61,13 @@ def test_with_run_command(self):
6261
"frame variable v3",
6362
substrs=["v3 = Active Type = char {", "Value = 'A'", "}"],
6463
)
65-
"""
66-
TODO: temporarily disable No Value tests as they seem to fail on ubuntu/debian
67-
bots. Pending reproduce and investigation.
6864

6965
self.expect("frame variable v_no_value", substrs=["v_no_value = No Value"])
7066

7167
self.expect(
7268
"frame variable v_many_types_no_value",
7369
substrs=["v_many_types_no_value = No Value"],
7470
)
75-
"""
7671

7772
@add_test_categories(["libstdcxx"])
7873
def test_invalid_variant_index(self):

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ int main() {
4949
v1 = 12; // v contains int
5050
v1_typedef = v1;
5151
v_v1 = v1;
52+
v1_typedef = v1;
5253
int i = std::get<int>(v1);
5354
printf("%d\n", i); // break here
5455

0 commit comments

Comments
 (0)