Bug 1610570: Pass attributes through so lower.py can change code emission, and handle NoTaint r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D108246
This commit is contained in:
Tom Ritter 2021-03-23 18:26:30 +00:00
Родитель 7275e370ec
Коммит a40387b8a8
3 изменённых файлов: 9 добавлений и 6 удалений

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

@ -417,3 +417,4 @@ class Decl(Node):
self.loc = loc
self.type = None
self.scope = None
self.attributes = {}

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

@ -707,9 +707,10 @@ class _HybridDecl:
"""A hybrid decl stores both an IPDL type and all the C++ type
info needed by later passes, along with a basic name for the decl."""
def __init__(self, ipdltype, name):
def __init__(self, ipdltype, name, attributes={}):
self.ipdltype = ipdltype
self.name = name
self.attributes = attributes
def var(self):
return ExprVar(self.name)
@ -1115,7 +1116,7 @@ class MessageDecl(ipdl.ast.MessageDecl):
|params| and |returns| is the C++ semantics of those: 'in', 'out', or None."""
def makeDecl(d, sems):
if self.decl.type.tainted and direction == "recv":
if self.decl.type.tainted and 'NoTaint' not in d.attributes and direction == "recv":
# Tainted types are passed by-value, allowing the receiver to move them if desired.
assert sems != "out"
return Decl(Type("Tainted", T=d.bareType(side)), d.name)
@ -1513,7 +1514,7 @@ class _DecorateWithCxxStuff(ipdl.ast.Visitor):
self.typedefSet.add(Typedef(Type(ud.fqClassName()), ud.name))
def visitDecl(self, decl):
return _HybridDecl(decl.type, decl.progname)
return _HybridDecl(decl.type, decl.progname, decl.attributes)
def visitMessageDecl(self, md):
md.namespace = self.protocolName
@ -5119,7 +5120,7 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
Decl(
(
Type("Tainted", T=p.bareType(side))
if md.decl.type.tainted
if md.decl.type.tainted and 'NoTaint' not in p.attributes
else p.bareType(side)
),
p.var().name,

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

@ -828,12 +828,13 @@ class GatherDecls(TcheckVisitor):
self.symtab = None
self.builtinUsing = builtinUsing
def declare(self, loc, type, shortname=None, fullname=None, progname=None):
def declare(self, loc, type, shortname=None, fullname=None, progname=None, attributes={}):
d = Decl(loc)
d.type = type
d.progname = progname
d.shortname = shortname
d.fullname = fullname
d.attributes = attributes
self.symtab.declare(d)
return d
@ -1326,7 +1327,7 @@ class GatherDecls(TcheckVisitor):
ptype = VOID
else:
ptype = self._canonicalType(ptdecl.type, param.typespec)
return self.declare(loc=ploc, type=ptype, progname=param.name)
return self.declare(loc=ploc, type=ptype, progname=param.name, attributes=param.attributes)
for i, inparam in enumerate(md.inParams):
pdecl = paramToDecl(inparam)