Skip to content

Commit 2ff8278

Browse files
committed
fixup! use CreateValueObjectFromData; add test-case; remove redundant Scalar::IsValid check
1 parent 09205d7 commit 2ff8278

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

lldb/source/API/SBType.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -709,15 +709,18 @@ lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
709709
return {};
710710

711711
Scalar value{arg->value};
712+
DataExtractor data;
713+
value.GetData(data);
712714

713-
if (!value.IsValid())
715+
ExecutionContext exe_ctx;
716+
auto target_sp = target.GetSP();
717+
if (!target_sp)
714718
return {};
715719

716-
DataExtractor data;
717-
value.GetData(data);
720+
target_sp->CalculateExecutionContext(exe_ctx);
718721

719-
return SBValue(ValueObjectConstResult::Create(target.GetSP().get(), arg->type,
720-
ConstString("value"), data));
722+
return ValueObject::CreateValueObjectFromData("value", data, exe_ctx,
723+
arg->type);
721724
}
722725

723726
SBType SBType::FindDirectNestedType(const char *name) {

lldb/test/API/lang/cpp/template-arguments/TestCppTemplateArguments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def test(self):
4646
self.assertEqual(template_type.GetTemplateArgumentType(2).GetName(), "")
4747

4848
value = self.expect_expr("temp2", result_type="Foo<short, -2>")
49+
50+
# Can't get template parameter value with invalid target.
51+
self.assertFalse(value.GetType().GetTemplateArgumentValue(lldb.SBTarget(), 1))
52+
4953
template_param_value = value.GetType().GetTemplateArgumentValue(target, 1)
5054
self.assertTrue(template_param_value)
5155
self.assertEqual(template_param_value.GetTypeName(), "short")

0 commit comments

Comments
 (0)