r216166 - Fix invalid test generation by utils/ABITest/ABITestGen.py when the same enum is generated more than once.

Daniel Sanders daniel.sanders at imgtec.com
Thu Aug 21 03:13:50 PDT 2014


Author: dsanders
Date: Thu Aug 21 05:13:49 2014
New Revision: 216166

URL: http://llvm.org/viewvc/llvm-project?rev=216166&view=rev
Log:
Fix invalid test generation by utils/ABITest/ABITestGen.py when the same enum is generated more than once.

When generating records/unions, the same enum type may be generated more
than once (with different names). In these cases, the name of the enum
values are not sufficiently unique to prevent multiple declarations. E.g:
  typedef enum T3 { enum0val0 } T3;
  typedef T3 T2[3];
  typedef enum T4 { enum0val0 } T4;
  typedef union T1 { T2 field0; T4 field1; char field2; } T1;

Added a unique suffix to enum values so that multiple identical enum types do
not use the same enum value names.

One example of this bug is produced by:
  ABITestGen.py --no-unsigned --no-vector --no-complex --no-bool \
                --max-args 0 --max-record-depth 1 -o inputs/test.9921.a.c \
                -T inputs/test.9921.b.c -D inputs/test.9921.driver.c \
                --min=9921 --count=1

Modified:
    cfe/trunk/utils/ABITest/ABITestGen.py
    cfe/trunk/utils/ABITest/TypeGen.py

Modified: cfe/trunk/utils/ABITest/ABITestGen.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/ABITestGen.py?rev=216166&r1=216165&r2=216166&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/ABITestGen.py (original)
+++ cfe/trunk/utils/ABITest/ABITestGen.py Thu Aug 21 05:13:49 2014
@@ -214,7 +214,7 @@ class TypePrinter:
                 yield '(%s) 1'%(t.name,)
         elif isinstance(t, EnumType):
             for i in range(0, len(t.enumerators)):
-                yield 'enum%dval%d' % (t.index, i)
+                yield 'enum%dval%d_%d' % (t.index, i, t.unique_id)
         elif isinstance(t, RecordType):
             nonPadding = [f for f in t.fields 
                           if not f.isPaddingBitField()]

Modified: cfe/trunk/utils/ABITest/TypeGen.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/TypeGen.py?rev=216166&r1=216165&r2=216166&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/TypeGen.py (original)
+++ cfe/trunk/utils/ABITest/TypeGen.py Thu Aug 21 05:13:49 2014
@@ -56,16 +56,20 @@ class BuiltinType(Type):
         return self.name
 
 class EnumType(Type):
+    unique_id = 0
+
     def __init__(self, index, enumerators):
         self.index = index
         self.enumerators = enumerators
+        self.unique_id = self.__class__.unique_id
+        self.__class__.unique_id += 1
 
     def getEnumerators(self):
         result = ''
         for i, init in enumerate(self.enumerators):
             if i > 0:
                 result = result + ', '
-            result = result + 'enum%dval%d' % (self.index, i)
+            result = result + 'enum%dval%d_%d' % (self.index, i, self.unique_id)
             if init:
                 result = result + ' = %s' % (init)
 





More information about the cfe-commits mailing list