forked from M-Labs/artiq
1
0
Fork 0

validators.escape: cache_get result lives forever.

This commit is contained in:
whitequark 2016-01-10 14:43:21 +00:00
parent f8e50f2b0c
commit 211af77e77
2 changed files with 14 additions and 3 deletions

View File

@ -610,8 +610,13 @@ def is_function(typ):
def is_rpc_function(typ):
return isinstance(typ.find(), TRPCFunction)
def is_c_function(typ):
return isinstance(typ.find(), TCFunction)
def is_c_function(typ, name=None):
typ = typ.find()
if name is None:
return isinstance(typ, TCFunction)
else:
return isinstance(typ, TCFunction) and \
typ.name == name
def is_builtin(typ, name=None):
typ = typ.find()

View File

@ -87,7 +87,13 @@ class RegionOf(algorithm.Visitor):
return None
visit_BinOpT = visit_sometimes_allocating
visit_CallT = visit_sometimes_allocating
def visit_CallT(self, node):
if types.is_c_function(node.func.type, "cache_get"):
# The cache is borrow checked dynamically
return None
else:
self.visit_sometimes_allocating(node)
# Value lives as long as the object/container, if it's mutable,
# or else forever