Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

utils/ABITest: Factor out type naming code slightly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114867 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information...
commit 7b1ab134383b0ecb1a3c9042e5da227e94c111ca 1 parent 3d2fd8d
@ddunbar ddunbar authored
Showing with 24 additions and 10 deletions.
  1. +15 −10 utils/ABITest/ABITestGen.py
  2. +9 −0 utils/ABITest/TypeGen.py
View
25 utils/ABITest/ABITestGen.py
@@ -23,6 +23,7 @@ def __init__(self, output, outputHeader=None,
self.testValues = {}
self.testReturnValues = {}
self.layoutTests = []
+ self.declarations = set()
if info:
for f in (self.output,self.outputHeader,self.outputTests,self.outputDriver):
@@ -64,21 +65,25 @@ def finish(self):
print >>self.outputDriver, ' return 0;'
print >>self.outputDriver, '}'
+ def addDeclaration(self, decl):
+ if decl in self.declarations:
+ return False
+
+ self.declarations.add(decl)
+ if self.outputHeader:
+ print >>self.outputHeader, decl
+ else:
+ print >>self.output, decl
+ if self.outputTests:
+ print >>self.outputTests, decl
+ return True
+
def getTypeName(self, T):
- if isinstance(T,BuiltinType):
- return T.name
name = self.types.get(T)
if name is None:
- name = 'T%d'%(len(self.types),)
# Reserve slot
self.types[T] = None
- if self.outputHeader:
- print >>self.outputHeader,T.getTypedefDef(name, self)
- else:
- print >>self.output,T.getTypedefDef(name, self)
- if self.outputTests:
- print >>self.outputTests,T.getTypedefDef(name, self)
- self.types[T] = name
+ self.types[T] = name = T.getTypeName(self)
return name
def writeLayoutTest(self, i, ty):
View
9 utils/ABITest/TypeGen.py
@@ -24,6 +24,12 @@ def isBitField(self):
def isPaddingBitField(self):
return False
+ def getTypeName(self, printer):
+ name = 'T%d' % len(printer.types)
+ typedef = self.getTypedefDef(name, printer)
+ printer.addDeclaration(typedef)
+ return name
+
class BuiltinType(Type):
def __init__(self, name, size, bitFieldSize=None):
self.name = name
@@ -40,6 +46,9 @@ def getBitFieldSize(self):
assert self.isBitField()
return self.bitFieldSize
+ def getTypeName(self, printer):
+ return self.name
+
def sizeof(self):
return self.size
Please sign in to comment.
Something went wrong with that request. Please try again.