Skip to content

Commit 0dca566

Browse files
committed
Revert "Detect against invalid variant index for LibStdC++ std::variant data formatters (llvm#69253)"
This reverts commit 659a48f. This caused another test to fail on Windows AArch64 and x86_64, and AArch64 Linux.
1 parent 104db26 commit 0dca566

File tree

3 files changed

+0
-34
lines changed

3 files changed

+0
-34
lines changed

lldb/examples/synthetic/gnu_libstdcpp.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -914,11 +914,6 @@ def get_variant_npos_value(index_byte_size):
914914
if index == npos_value:
915915
return " No Value"
916916

917-
# Invalid index can happen when the variant is not initialized yet.
918-
template_arg_count = data_obj.GetType().GetNumberOfTemplateArguments()
919-
if index >= template_arg_count:
920-
return " <Invalid>"
921-
922917
active_type = data_obj.GetType().GetTemplateArgumentType(index)
923918
return f" Active Type = {active_type.GetDisplayTypeName()} "
924919

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7182,9 +7182,6 @@ GetNthTemplateArgument(const clang::ClassTemplateSpecializationDecl *decl,
71827182
// Note that 'idx' counts from the beginning of all template arguments
71837183
// (including the ones preceding the parameter pack).
71847184
const auto &pack = args[last_idx];
7185-
if (idx >= pack.pack_size())
7186-
return nullptr;
7187-
71887185
const size_t pack_idx = idx - last_idx;
71897186
assert(pack_idx < pack.pack_size() && "parameter pack index out-of-bounds");
71907187
return &pack.pack_elements()[pack_idx];

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,3 @@ def test_with_run_command(self):
7171
substrs=["v_many_types_no_value = No Value"],
7272
)
7373
"""
74-
75-
@add_test_categories(["libstdcxx"])
76-
def test_invalid_variant_index(self):
77-
"""Test LibStdC++ data formatter for std::variant with invalid index."""
78-
self.build()
79-
80-
(self.target, self.process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
81-
self, "// break here", lldb.SBFileSpec("main.cpp", False)
82-
)
83-
84-
lldbutil.continue_to_breakpoint(self.process, bkpt)
85-
86-
self.expect(
87-
"frame variable v1",
88-
substrs=["v1 = Active Type = int {", "Value = 12", "}"],
89-
)
90-
91-
var_v1 = thread.frames[0].FindVariable("v1")
92-
var_v1_raw_obj = var_v1.GetNonSyntheticValue()
93-
index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index")
94-
self.assertTrue(index_obj and index_obj.IsValid())
95-
96-
INVALID_INDEX = "100"
97-
index_obj.SetValueFromCString(INVALID_INDEX)
98-
99-
self.expect("frame variable v1", substrs=["v1 = <Invalid>"])

0 commit comments

Comments
 (0)