<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58492>58492</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lldb Not able to get the right template argument type via python API.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dprogm
</td>
</tr>
</table>
<pre>
I am currently trying to write my own data formatter for some variadic template class. Here is a simple example:
```cpp
template<typename...T>
class MyVariadic
{
private:
int which{1};
};
int main()
{
MyVariadic<int, float> myVariadic;
return 0;
}
```
The corresponding data formatter looks like this:
```python
class MyVariadicSyntheticChildrenProvider:
def __init__(self, valobj, internal_dict):
self.valobj = valobj
def num_children(self):
return 1
def has_children(self):
return True
def get_child_index(self, name):
return None
def get_child_at_index(self, index):
which = self.valobj.GetChildMemberWithName('which').signed
numberOfArgs = self.valobj.GetType().GetNumberOfTemplateArguments()
print("Number of Args: ", numberOfArgs)
templateType = self.valobj.GetType().GetTemplateArgumentType(which)
print("Template Type: ", templateType)
return None
def update(self):
pass
def __lldb_init_module(debugger, dict):
debugger.HandleCommand('type synthetic add -l type_formatters.MyVariadicSyntheticChildrenProvider -x "^MyVariadic<.+>$')
```
**My expectations are:**
- `GetNumberOfTemplateArguments()` returns 2, but it actually returns 1
- `GetTemplateArgumentType(which)` returns float, but it actually returns 'No Value'
I was also trying to get the type via `target.FindFirstType(typeAsString)` but without success. A similar issue can be found here https://github.com/llvm/llvm-project/issues/31647.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydVVtvozoQ_jXkZVREINcHHtJ0c7YP7a600Z7HyOAJeNdgZJuk-fc7NqQhTU-3OhIC4_F8M_N5Lpnip_QRWAV5qzXWVp7A6pOoC7AKjlpYhOoE6lgDZ5bBXumKWYvarcCoCuHAtGBc5GCxaiQjhVwyY0L4ihpBGGBgBEkQ8IW5b5CsgughiFbBLOqevGm6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