[Lldb-commits] [lldb] [lldb][SBAPI] Add new SBType::GetTemplateParameterValue API (PR #126901)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 12 05:02:18 PST 2025


================
@@ -687,6 +687,39 @@ lldb::TemplateArgumentKind SBType::GetTemplateArgumentKind(uint32_t idx) {
   return eTemplateArgumentKindNull;
 }
 
+lldb::SBValue SBType::GetTemplateArgumentValue(lldb::SBTarget target,
+                                               uint32_t idx) {
+  LLDB_INSTRUMENT_VA(this, target, idx);
+
+  if (!IsValid())
+    return {};
+
+  std::optional<CompilerType::IntegralTemplateArgument> arg;
+  const bool expand_pack = true;
+  switch (GetTemplateArgumentKind(idx)) {
+  case eTemplateArgumentKindIntegral:
+    arg = m_opaque_sp->GetCompilerType(false).GetIntegralTemplateArgument(
+        idx, expand_pack);
+    break;
+  default:
+    break;
+  }
+
+  if (!arg)
+    return {};
+
+  Scalar value{arg->value};
+
+  if (!value.IsValid())
+    return {};
+
+  DataExtractor data;
+  value.GetData(data);
+
+  return SBValue(ValueObjectConstResult::Create(target.GetSP().get(), arg->type,
----------------
labath wrote:

How about `ValueObject::CreateValueObjectFromData` ? It looks like it calls the same function underneath, but it seem more correct.

https://github.com/llvm/llvm-project/pull/126901


More information about the lldb-commits mailing list