mirror of
https://github.com/github/codeql.git
synced 2026-03-17 04:56:58 +01:00
Python: Give most non-self instance attributes the 'unknown' value; improves reachability analysis.
This commit is contained in:
@@ -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
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user