commit 696dc649db2ea7d8f05814e902ea5ac000a2e7a6 Author: David Malcolm dmalcolm@redhat.com Date: Fri Sep 23 19:00:56 2011 -0400
cpychecker: remove dead code ("owned_refs" field of MyState)
The "owned_refs" field of MyState and the related methods were remnants of an early attempt at reference-count tracking, but haven't been used in a long time: remove them.
The MyState.mktrans_assignment() overridden method is removed; the base State.mktrans_assignment() does all we need.
libcpychecker/absinterp.py | 5 ----- libcpychecker/refcounts.py | 24 +----------------------- 2 files changed, 1 insertions(+), 28 deletions(-) --- diff --git a/libcpychecker/absinterp.py b/libcpychecker/absinterp.py index 9025ef9..daa598b 100644 --- a/libcpychecker/absinterp.py +++ b/libcpychecker/absinterp.py @@ -946,9 +946,6 @@ class Trace: def return_value(self): return self.states[-1].return_rvalue
- def final_references(self): - return self.states[-1].owned_refs - def has_looped(self): """ Is the tail state of the Trace at a location where it's been before? @@ -1035,7 +1032,6 @@ def iter_traces(fun, stateclass, prefix=None, limits=None): prefix = Trace() curstate = stateclass(Location.get_block_start(fun.cfg.entry), None, None, None, - [], Resources(), ConcreteValue(get_PyObjectPtr(), fun.start, 0)) curstate.init_for_function(fun) @@ -1127,7 +1123,6 @@ class StateGraph: # Recursively gather states: initial = stateclass(Location.get_block_start(fun.cfg.entry), None, None, None, - [], Resources(), ConcreteValue(get_PyObjectPtr(), fun.start, 0)) initial.init_for_function(fun) diff --git a/libcpychecker/refcounts.py b/libcpychecker/refcounts.py index 8a3af47..2941cd5 100644 --- a/libcpychecker/refcounts.py +++ b/libcpychecker/refcounts.py @@ -191,9 +191,8 @@ class GenericTpDealloc(AbstractValue): return [Transition(state, new, desc)]
class MyState(State): - def __init__(self, loc, region_for_var, value_for_region, return_rvalue, owned_refs, resources, exception_rvalue): + def __init__(self, loc, region_for_var, value_for_region, return_rvalue, resources, exception_rvalue): State.__init__(self, loc, region_for_var, value_for_region, return_rvalue) - self.owned_refs = owned_refs self.resources = resources self.exception_rvalue = exception_rvalue
@@ -202,16 +201,12 @@ class MyState(State): self.region_for_var.copy(), self.value_for_region.copy(), self.return_rvalue, - self.owned_refs[:], self.resources.copy(), self.exception_rvalue) if hasattr(self, 'fun'): c.fun = self.fun return c
- def _extra(self): - return ' %s' % self.owned_refs - def acquire(self, resource): self.resources.acquire(resource)
@@ -248,14 +243,6 @@ class MyState(State): typeobjregion) self.verify()
- def mktrans_assignment(self, key, value, desc, additional_ptr=None): - if desc: - check_isinstance(desc, str) - transition = State.mktrans_assignment(self, key, value, desc) - if additional_ptr: - transition.dest.owned_refs.append(additional_ptr) - return transition - def get_transitions(self): # Return a list of Transition instances, based on input State stmt = self.loc.get_stmt() @@ -2037,15 +2024,6 @@ class MyState(State): raise ReadFromDeallocatedMemory(stmt, value)
nextstate = self.use_next_loc() - """ - if isinstance(stmt.lhs, gcc.MemRef): - log('value: %s %r', value, value) - # We're writing a value to memory; if it's a PyObject* - # then we're surrending a reference on it: - if value in nextstate.owned_refs: - log('removing ownership of %s', value) - nextstate.owned_refs.remove(value) - """ return [self.mktrans_assignment(stmt.lhs, value, None)]
gcc-python-plugin-commits@lists.stg.fedorahosted.org