Python: Give most non-self instance attributes the 'unknown' value; improves reachability analysis.

This commit is contained in:
Mark Shannon
2019-01-31 12:54:19 +00:00
parent 54242f4009
commit f190f83406
5 changed files with 11 additions and 1 deletions

View File

@@ -610,7 +610,6 @@ module PointsTo {
points_to(obj_node, context, x, icls, _) and
(not x instanceof ModuleObject and not x instanceof ClassObject) and
not icls.isBuiltin() and
Types::class_has_attribute_bool(icls, name) = false and
value = unknownValue() and cls = theUnknownType() and origin = f
)
)

View File

@@ -61,6 +61,7 @@
| test.py | 408 | ControlFlowNode for x | int 1 | 404 |
| test.py | 420 | ControlFlowNode for Attribute | NoneType None | 418 |
| test.py | 427 | ControlFlowNode for Attribute | NoneType None | 418 |
| test.py | 435 | ControlFlowNode for y | int 1 | 433 |
| type_test.py | 5 | ControlFlowNode for d | Dict | 2 |
| type_test.py | 14 | ControlFlowNode for x | int 0 | 11 |
| type_test.py | 16 | ControlFlowNode for x | float 1.0 | 11 |

View File

@@ -61,6 +61,7 @@
| test.py | 408 | ControlFlowNode for x | int 1 | builtin-class int | 404 |
| test.py | 420 | ControlFlowNode for Attribute | NoneType None | builtin-class NoneType | 418 |
| test.py | 427 | ControlFlowNode for Attribute | NoneType None | builtin-class NoneType | 418 |
| test.py | 435 | ControlFlowNode for y | int 1 | builtin-class int | 433 |
| type_test.py | 5 | ControlFlowNode for d | Dict | builtin-class dict | 2 |
| type_test.py | 14 | ControlFlowNode for x | int 0 | builtin-class int | 11 |
| type_test.py | 16 | ControlFlowNode for x | float 1.0 | builtin-class float | 11 |

View File

@@ -426,3 +426,10 @@ class C(object):
else:
use(self.x)
return lambda : use(self.x)
def test_on_unknown_attr():
e = E()
y = 1
if e.attr:
use(y)

View File

@@ -225,3 +225,5 @@
| r_regressions.py:52 | ControlFlowNode for msg | 51 |
| r_regressions.py:64 | ControlFlowNode for do_validation | 64 |
| r_regressions.py:64 | ControlFlowNode for do_validation() | 64 |
| r_regressions.py:90 | ControlFlowNode for Attribute | 90 |
| r_regressions.py:90 | ControlFlowNode for Attribute() | 90 |