@@ -13,7 +13,7 @@ import semmle.python.essa.SsaDefinitions
13
13
private import semmle.python.types.Builtins
14
14
private import semmle.python.internal.CachedStages
15
15
16
- module BasePointsTo {
16
+ deprecated module BasePointsTo {
17
17
/** INTERNAL -- Use n.refersTo(value, _, origin) instead */
18
18
pragma [ noinline]
19
19
predicate points_to ( ControlFlowNode f , Object value , ControlFlowNode origin ) {
@@ -27,13 +27,13 @@ module BasePointsTo {
27
27
}
28
28
29
29
/** Gets the kwargs parameter (`**kwargs`). In a function definition this is always a dict. */
30
- predicate kwargs_points_to ( ControlFlowNode f , ClassObject cls ) {
30
+ deprecated predicate kwargs_points_to ( ControlFlowNode f , ClassObject cls ) {
31
31
exists ( Function func | func .getKwarg ( ) = f .getNode ( ) ) and
32
32
cls = theDictType ( )
33
33
}
34
34
35
35
/** Gets the varargs parameter (`*varargs`). In a function definition this is always a tuple. */
36
- predicate varargs_points_to ( ControlFlowNode f , ClassObject cls ) {
36
+ deprecated predicate varargs_points_to ( ControlFlowNode f , ClassObject cls ) {
37
37
exists ( Function func | func .getVararg ( ) = f .getNode ( ) ) and
38
38
cls = theTupleType ( )
39
39
}
@@ -45,7 +45,7 @@ predicate varargs_points_to(ControlFlowNode f, ClassObject cls) {
45
45
* This exists primarily for internal use. Use getAnInferredType() instead.
46
46
*/
47
47
pragma [ noinline]
48
- ClassObject simple_types ( Object obj ) {
48
+ deprecated ClassObject simple_types ( Object obj ) {
49
49
result = comprehension ( obj .getOrigin ( ) )
50
50
or
51
51
result = collection_literal ( obj .getOrigin ( ) )
@@ -59,7 +59,7 @@ ClassObject simple_types(Object obj) {
59
59
obj = unknownValue ( ) and result = theUnknownType ( )
60
60
}
61
61
62
- private ClassObject comprehension ( Expr e ) {
62
+ deprecated private ClassObject comprehension ( Expr e ) {
63
63
e instanceof ListComp and result = theListType ( )
64
64
or
65
65
e instanceof SetComp and result = theSetType ( )
@@ -69,7 +69,7 @@ private ClassObject comprehension(Expr e) {
69
69
e instanceof GeneratorExp and result = theGeneratorType ( )
70
70
}
71
71
72
- private ClassObject collection_literal ( Expr e ) {
72
+ deprecated private ClassObject collection_literal ( Expr e ) {
73
73
e instanceof List and result = theListType ( )
74
74
or
75
75
e instanceof Set and result = theSetType ( )
@@ -79,7 +79,7 @@ private ClassObject collection_literal(Expr e) {
79
79
e instanceof Tuple and result = theTupleType ( )
80
80
}
81
81
82
- private int tuple_index_value ( Object t , int i ) {
82
+ deprecated private int tuple_index_value ( Object t , int i ) {
83
83
result = t .( TupleNode ) .getElement ( i ) .getNode ( ) .( Num ) .getN ( ) .toInt ( )
84
84
or
85
85
exists ( Object item |
@@ -89,7 +89,7 @@ private int tuple_index_value(Object t, int i) {
89
89
}
90
90
91
91
pragma [ noinline]
92
- int version_tuple_value ( Object t ) {
92
+ deprecated int version_tuple_value ( Object t ) {
93
93
not exists ( tuple_index_value ( t , 1 ) ) and result = tuple_index_value ( t , 0 ) * 10
94
94
or
95
95
not exists ( tuple_index_value ( t , 2 ) ) and
@@ -102,7 +102,7 @@ int version_tuple_value(Object t) {
102
102
}
103
103
104
104
/** Choose a version numbers that represent the extreme of supported versions. */
105
- private int major_minor ( ) {
105
+ deprecated private int major_minor ( ) {
106
106
if major_version ( ) = 3
107
107
then (
108
108
result = 33 or result = 37
@@ -113,7 +113,7 @@ private int major_minor() {
113
113
}
114
114
115
115
/** Compares the given tuple object to both the maximum and minimum possible sys.version_info values */
116
- int version_tuple_compare ( Object t ) {
116
+ deprecated int version_tuple_compare ( Object t ) {
117
117
version_tuple_value ( t ) < major_minor ( ) and result = - 1
118
118
or
119
119
version_tuple_value ( t ) = major_minor ( ) and result = 0
@@ -122,7 +122,7 @@ int version_tuple_compare(Object t) {
122
122
}
123
123
124
124
/** Holds if `cls` is a new-style class if it were to have no explicit base classes */
125
- predicate baseless_is_new_style ( ClassObject cls ) {
125
+ deprecated predicate baseless_is_new_style ( ClassObject cls ) {
126
126
cls .isBuiltin ( )
127
127
or
128
128
major_version ( ) = 3 and exists ( cls )
@@ -160,7 +160,7 @@ private predicate class_defines_name(Class cls, string name) {
160
160
}
161
161
162
162
/** Gets a return value CFG node, provided that is safe to track across returns */
163
- ControlFlowNode safe_return_node ( PyFunctionObject func ) {
163
+ deprecated ControlFlowNode safe_return_node ( PyFunctionObject func ) {
164
164
result = func .getAReturnedNode ( ) and
165
165
// Not a parameter
166
166
not exists ( Parameter p , SsaVariable pvar |
@@ -172,7 +172,7 @@ ControlFlowNode safe_return_node(PyFunctionObject func) {
172
172
}
173
173
174
174
/** Holds if it can be determined from the control flow graph alone that this function can never return */
175
- predicate function_can_never_return ( FunctionObject func ) {
175
+ deprecated predicate function_can_never_return ( FunctionObject func ) {
176
176
/*
177
177
* A Python function never returns if it has no normal exits that are not dominated by a
178
178
* call to a function which itself never returns.
@@ -188,7 +188,9 @@ predicate function_can_never_return(FunctionObject func) {
188
188
189
189
/** Hold if outer contains inner, both are contained within a test and inner is a use is a plain use or an attribute lookup */
190
190
pragma [ noinline]
191
- predicate contains_interesting_expression_within_test ( ControlFlowNode outer , ControlFlowNode inner ) {
191
+ deprecated predicate contains_interesting_expression_within_test (
192
+ ControlFlowNode outer , ControlFlowNode inner
193
+ ) {
192
194
inner .isLoad ( ) and
193
195
exists ( ControlFlowNode test |
194
196
outer .getAChild * ( ) = inner and
@@ -208,7 +210,7 @@ predicate test_contains(ControlFlowNode expr, ControlFlowNode use) {
208
210
}
209
211
210
212
/** Holds if `test` is a test (a branch), `use` is within that test and `def` is an edge from that test with `sense` */
211
- predicate refinement_test (
213
+ deprecated predicate refinement_test (
212
214
ControlFlowNode test , ControlFlowNode use , boolean sense , PyEdgeRefinement def
213
215
) {
214
216
/*
@@ -224,7 +226,7 @@ predicate refinement_test(
224
226
225
227
/** Holds if `f` is an import of the form `from .[...] import name` and the enclosing scope is an __init__ module */
226
228
pragma [ noinline]
227
- predicate live_import_from_dot_in_init ( ImportMemberNode f , EssaVariable var ) {
229
+ deprecated predicate live_import_from_dot_in_init ( ImportMemberNode f , EssaVariable var ) {
228
230
exists ( string name |
229
231
import_from_dot_in_init ( f .getModule ( name ) ) and
230
232
var .getSourceVariable ( ) .getName ( ) = name and
@@ -249,13 +251,13 @@ Object undefinedVariable() { py_special_objects(result, "_semmle_undefined_value
249
251
/** Gets the pseudo-object representing an unknown value */
250
252
Object unknownValue ( ) { result .asBuiltin ( ) = Builtin:: unknown ( ) }
251
253
252
- BuiltinCallable theTypeNewMethod ( ) {
254
+ deprecated BuiltinCallable theTypeNewMethod ( ) {
253
255
result .asBuiltin ( ) = theTypeType ( ) .asBuiltin ( ) .getMember ( "__new__" )
254
256
}
255
257
256
258
/** Gets the `value, cls, origin` that `f` would refer to if it has not been assigned some other value */
257
259
pragma [ noinline]
258
- predicate potential_builtin_points_to (
260
+ deprecated predicate potential_builtin_points_to (
259
261
NameNode f , Object value , ClassObject cls , ControlFlowNode origin
260
262
) {
261
263
f .isGlobal ( ) and
@@ -269,7 +271,7 @@ predicate potential_builtin_points_to(
269
271
}
270
272
271
273
pragma [ noinline]
272
- predicate builtin_name_points_to ( string name , Object value , ClassObject cls ) {
274
+ deprecated predicate builtin_name_points_to ( string name , Object value , ClassObject cls ) {
273
275
value = Object:: builtin ( name ) and cls .asBuiltin ( ) = value .asBuiltin ( ) .getClass ( )
274
276
}
275
277
@@ -331,7 +333,9 @@ module BaseFlow {
331
333
}
332
334
333
335
/** Points-to for syntactic elements where context is not relevant */
334
- predicate simple_points_to ( ControlFlowNode f , Object value , ClassObject cls , ControlFlowNode origin ) {
336
+ deprecated predicate simple_points_to (
337
+ ControlFlowNode f , Object value , ClassObject cls , ControlFlowNode origin
338
+ ) {
335
339
kwargs_points_to ( f , cls ) and value = f and origin = f
336
340
or
337
341
varargs_points_to ( f , cls ) and value = f and origin = f
@@ -347,7 +351,9 @@ predicate simple_points_to(ControlFlowNode f, Object value, ClassObject cls, Con
347
351
* Holds if `bit` is a binary expression node with a bitwise operator.
348
352
* Helper for `this_binary_expr_points_to`.
349
353
*/
350
- predicate bitwise_expression_node ( BinaryExprNode bit , ControlFlowNode left , ControlFlowNode right ) {
354
+ deprecated predicate bitwise_expression_node (
355
+ BinaryExprNode bit , ControlFlowNode left , ControlFlowNode right
356
+ ) {
351
357
exists ( Operator op | op = bit .getNode ( ) .getOp ( ) |
352
358
op instanceof BitAnd or
353
359
op instanceof BitOr or
@@ -357,13 +363,13 @@ predicate bitwise_expression_node(BinaryExprNode bit, ControlFlowNode left, Cont
357
363
right = bit .getRight ( )
358
364
}
359
365
360
- private Module theCollectionsAbcModule ( ) {
366
+ deprecated private Module theCollectionsAbcModule ( ) {
361
367
result .getName ( ) = "_abcoll"
362
368
or
363
369
result .getName ( ) = "_collections_abc"
364
370
}
365
371
366
- ClassObject collectionsAbcClass ( string name ) {
372
+ deprecated ClassObject collectionsAbcClass ( string name ) {
367
373
exists ( Class cls |
368
374
result .getPyClass ( ) = cls and
369
375
cls .getName ( ) = name and
0 commit comments