[lldb-dev] [Bug 32300] New: Wrong resolving boost::variant template arguments by formatters API
via lldb-dev
lldb-dev at lists.llvm.org
Thu Mar 16 01:12:02 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=32300
Bug ID: 32300
Summary: Wrong resolving boost::variant template arguments by
formatters API
Product: lldb
Version: 3.9
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: lldb-dev at lists.llvm.org
Reporter: andrew.stepanov.i at gmail.com
CC: llvm-bugs at lists.llvm.org
1. Use C++ code:
#include <boost/variant>
#include <vector>
#include <string>
template<typename ParentType>
struct Example
{
using Variant = boost::variant<int, std::string, std::vector<ParentType>>;
};
int main()
{
Example<float>::Variant ex(std::string("string"));
Example<float>::Variant ex2(10);
return ex.which() == ex2.which();
}
2. Use formatter for boost::variant:
import lldb
import lldb.formatters.Logger
def get_template_arg(valobj, i):
valobj_type = valobj.GetType().GetUnqualifiedType()
if valobj_type.IsReferenceType():
valobj_type = valobj_type.GetDereferencedType()
if valobj_type.GetNumberOfTemplateArguments() > i:
data_type = valobj_type.GetTemplateArgumentType(i)
else:
data_type = None
return data_type
class BoostVariantSynthProvider:
def __init__(self, valobj, dict):
self.val_obj = valobj
self.value = None
self.update()
def num_children(self):
return 1
def has_children(self):
return True
def get_child_index(self, name):
if name == "value":
return 0
return -1
def get_child_at_index(self, index):
if index == 0:
return self.value
return None
def update(self):
type_index =
self.val_obj.GetChildMemberWithName("which_").GetValueAsUnsigned()
element_type = get_template_arg(self.val_obj, type_index)
self.value =
self.val_obj.GetChildMemberWithName("storage_").GetChildMemberWithName("data_").
\
GetChildMemberWithName("buf").CreateChildAtOffset("value", 0,
element_type)
Actual:
GetNumberOfTemplateArguments() returns 1 for Example<float>::Variant type and
get_template_arg returns 'None'
Expected:
GetNumberOfTemplateArguments() should return 3 for Example<float>::Variant type
and get_template_arg should returns std::string type
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20170316/5f41ade4/attachment.html>
More information about the lldb-dev
mailing list