Python: ObjectAPI to ValueAPI: ReturnValueIgnored: Reorganizes predicates

This commit is contained in:
Rebecca Valentine
2020-04-01 14:41:49 -07:00
parent 09349f1957
commit cc53b15a5d
3 changed files with 8 additions and 8 deletions

View File

@@ -50,7 +50,7 @@ predicate returns_meaningful_value(FunctionValue f) {
*/
f.isBuiltin() and
f.(CallableObjectInternal).getAnInferredReturnType() != ClassValue::nonetype() and
f.getAnInferredReturnType() != ClassValue::nonetype() and
not f.getName() = "__import__"
)
}

View File

@@ -49,13 +49,6 @@ abstract class CallableObjectInternal extends ObjectInternal {
/* Callables aren't iterable */
override ObjectInternal getIterNext() { none() }
/** Gets a class that this function may return */
ClassValue getAnInferredReturnType() {
result = TBuiltinClassObject(this.(BuiltinFunctionObjectInternal).getReturnType())
or
result = TBuiltinClassObject(this.(BuiltinMethodObjectInternal).getReturnType())
}
}
/** Class representing Python functions */

View File

@@ -581,6 +581,13 @@ abstract class FunctionValue extends CallableValue {
exists(Expr expr, AstNode origin | expr.pointsTo(this, origin) | not origin instanceof Lambda)
)
}
/** Gets a class that this function may return */
ClassValue getAnInferredReturnType() {
result = TBuiltinClassObject(this.(BuiltinFunctionObjectInternal).getReturnType())
or
result = TBuiltinClassObject(this.(BuiltinMethodObjectInternal).getReturnType())
}
}
/** Class representing Python functions */