3 script import lldbDataFormatters
4 type synthetic add -x "^llvm::SmallVectorImpl<.+>$" -l lldbDataFormatters.SmallVectorSynthProvider
5 type synthetic add -x "^llvm::SmallVector<.+,.+>$" -l lldbDataFormatters.SmallVectorSynthProvider
8 # Pretty printer for llvm::SmallVector/llvm::SmallVectorImpl
9 class SmallVectorSynthProvider:
10 def __init__(self, valobj, dict):
12 self.update() # initialize this provider
14 def num_children(self):
15 begin = self.begin.GetValueAsUnsigned(0)
16 end = self.end.GetValueAsUnsigned(0)
17 return (end - begin)/self.type_size
19 def get_child_index(self, name):
21 return int(name.lstrip('[').rstrip(']'))
25 def get_child_at_index(self, index):
29 if index >= self.num_children():
32 offset = index * self.type_size
33 return self.begin.CreateChildAtOffset('['+str(index)+']',
34 offset, self.data_type)
37 self.begin = self.valobj.GetChildMemberWithName('BeginX')
38 self.end = self.valobj.GetChildMemberWithName('EndX')
39 the_type = self.valobj.GetType()
40 # If this is a reference type we have to dereference it to get to the
42 if the_type.IsReferenceType():
43 the_type = the_type.GetDereferencedType()
45 self.data_type = the_type.GetTemplateArgumentType(0)
46 self.type_size = self.data_type.GetByteSize()
47 assert self.type_size != 0