ABITest: Fix a bug in generating test values for structures w/ no

non-padding fields.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-05-08 22:48:39 +00:00
Родитель 8236bf1800
Коммит 48df17b8bf
1 изменённых файлов: 10 добавлений и 14 удалений

Просмотреть файл

@ -199,31 +199,27 @@ class TypePrinter:
yield '(%s) -1'%(t.name,)
yield '(%s) 1'%(t.name,)
elif isinstance(t, RecordType):
if not t.fields:
nonPadding = [f for f in t.fields
if not f.isPaddingBitField()]
if not nonPadding:
yield '{ }'
return
# FIXME: Use designated initializers to access non-first
# fields of unions.
if t.isUnion:
firstNonPadding = None
for t in t.fields:
if not t.isPaddingBitField():
firstNonPadding = t
break
if firstNonPadding:
for v in self.getTestValues(firstNonPadding):
yield '{ %s }' % v
else:
yield '{ }'
for v in self.getTestValues(nonPadding[0]):
yield '{ %s }' % v
return
fieldValues = [list(self.getTestValues(f))
for f in t.fields
if not f.isPaddingBitField()]
fieldValues = map(list, map(self.getTestValues, nonPadding))
for i,values in enumerate(fieldValues):
for v in values:
elements = map(random.choice,fieldValues)
elements[i] = v
yield '{ %s }'%(', '.join(elements))
elif isinstance(t, ComplexType):
for t in self.getTestValues(t.elementType):
yield '%s + %s * 1i'%(t,t)