Bug 1610570: Support the NoTaint attribute on method parameters with the passback value r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D108245
This commit is contained in:
Tom Ritter 2021-03-23 15:15:37 +00:00
Родитель 8f2ee22900
Коммит 63f2838313
5 изменённых файлов: 29 добавлений и 3 удалений

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

@ -355,10 +355,11 @@ class MessageDecl(Node):
class Param(Node):
def __init__(self, loc, typespec, name):
def __init__(self, loc, typespec, name, attributes={}):
Node.__init__(self, loc)
self.name = name
self.typespec = typespec
self.attributes = attributes
class TypeSpec(Node):

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

@ -633,8 +633,8 @@ def p_ParamList(p):
def p_Param(p):
"""Param : Type ID"""
p[0] = Param(locFromTok(p, 1), p[1], p[2])
"""Param : Attributes Type ID"""
p[0] = Param(locFromTok(p, 2), p[2], p[3], p[1])
def p_Type(p):

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

@ -1297,9 +1297,24 @@ class GatherDecls(TcheckVisitor):
# replace inparam Param nodes with proper Decls
def paramToDecl(param):
self.checkAttributes(
param.attributes,
{
"NoTaint": ("passback",)
},
)
ptname = param.typespec.basename()
ploc = param.typespec.loc
if 'NoTaint' in param.attributes and 'Tainted' not in md.attributes:
self.error(
ploc,
"argument typename `%s' of message `%s' has a NoTaint attribute, but the message lacks the Tainted attribute",
ptname,
msgname,
)
ptdecl = self.symtab.lookup(ptname)
if ptdecl is None:
self.error(

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

@ -0,0 +1,6 @@
//error: argument typename `int' of message `foo' has a NoTaint attribute, but the message lacks the Tainted attribute
intr protocol PNoTaintWithoutTainted {
child:
async foo([NoTaint=passback] int id);
};

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

@ -0,0 +1,4 @@
intr protocol PMessageTaintedWithPassback {
child:
[Tainted] async foo([NoTaint=passback] int id);
};