diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:31:36 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-02-16 09:31:36 +0000 |
commit | fd035e6496665b1f1197868e21cb0a4594e8db6e (patch) | |
tree | 53010172e19c77ea447bcd89e117cda052ab52e0 /utils/ABITest/ABITestGen.py | |
parent | 2fce988e86bc01829142e4362d4eff1af0925147 (diff) | |
download | FreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.zip FreeBSD-src-fd035e6496665b1f1197868e21cb0a4594e8db6e.tar.gz |
Update clang to r96341.
Diffstat (limited to 'utils/ABITest/ABITestGen.py')
-rwxr-xr-x | utils/ABITest/ABITestGen.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/utils/ABITest/ABITestGen.py b/utils/ABITest/ABITestGen.py index 63da02b..c45a0c3 100755 --- a/utils/ABITest/ABITestGen.py +++ b/utils/ABITest/ABITestGen.py @@ -42,7 +42,8 @@ class TypePrinter: print >>f, '#include "%s"\n'%(headerName,) if self.outputDriver: - print >>self.outputDriver, '#include <stdio.h>\n' + print >>self.outputDriver, '#include <stdio.h>' + print >>self.outputDriver, '#include <stdlib.h>\n' print >>self.outputDriver, 'int main(int argc, char **argv) {' print >>self.outputDriver, ' int index = -1;' print >>self.outputDriver, ' if (argc > 1) index = atoi(argv[1]);' @@ -206,6 +207,9 @@ class TypePrinter: yield '(%s) 0'%(t.name,) yield '(%s) -1'%(t.name,) yield '(%s) 1'%(t.name,) + elif isinstance(t, EnumType): + for i in range(0, len(t.enumerators)): + yield 'enum%dval%d' % (t.index, i) elif isinstance(t, RecordType): nonPadding = [f for f in t.fields if not f.isPaddingBitField()] @@ -272,6 +276,8 @@ class TypePrinter: else: code = 'p' print >>output, '%*sprintf("%s: %s = %%%s\\n", %s);'%(indent, '', prefix, name, code, name) + elif isinstance(t, EnumType): + print >>output, '%*sprintf("%s: %s = %%d\\n", %s);'%(indent, '', prefix, name, name) elif isinstance(t, RecordType): if not t.fields: print >>output, '%*sprintf("%s: %s (empty)\\n");'%(indent, '', prefix, name) @@ -300,6 +306,8 @@ class TypePrinter: output = self.output if isinstance(t, BuiltinType): print >>output, '%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS) + elif isinstance(t, EnumType): + print >>output, '%*sassert(%s == %s);' % (indent, '', nameLHS, nameRHS) elif isinstance(t, RecordType): for i,f in enumerate(t.fields): if f.isPaddingBitField(): @@ -402,6 +410,11 @@ def main(): help="do not generate void* types", action="store_false", default=True) + # Enumerations + group.add_option("", "--no-enums", dest="useEnum", + help="do not generate enum types", + action="store_false", default=True) + # Derived types group.add_option("", "--no-array", dest="useArray", help="do not generate record types", @@ -529,6 +542,8 @@ def main(): vTypes.append(ArrayType(i, True, type, count * type.size)) atg.addGenerator(FixedTypeGenerator(vTypes)) + if opts.useEnum: + atg.addGenerator(EnumTypeGenerator([None, '-1', '1', '1u'], 1, 4)) if opts.recordMaxDepth is None: # Fully recursive, just avoid top-level arrays. |