Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7ce905a

Browse files
committed
Python: Adds preliminary modernization
1 parent be09c17 commit 7ce905a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

python/ql/src/Functions/ReturnValueIgnored.ql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ predicate meaningful_return_value(Expr val) {
2121
or
2222
val instanceof BooleanLiteral
2323
or
24-
exists(FunctionObject callee | val = callee.getACall().getNode() and returns_meaningful_value(callee))
24+
exists(FunctionValue callee | val = callee.getACall().getNode() and returns_meaningful_value(callee))
2525
or
26-
not exists(FunctionObject callee | val = callee.getACall().getNode()) and not val instanceof Name
26+
not exists(FunctionValue callee | val = callee.getACall().getNode()) and not val instanceof Name
2727
}
2828

2929
/* Value is used before returning, and thus its value is not lost if ignored */
3030
predicate used_value(Expr val) {
3131
exists(LocalVariable var, Expr other | var.getAnAccess() = val and other = var.getAnAccess() and not other = val)
3232
}
3333

34-
predicate returns_meaningful_value(FunctionObject f) {
35-
not exists(f.getFunction().getFallthroughNode())
34+
predicate returns_meaningful_value(FunctionValue f) {
35+
not exists(f.getScope().getFallthroughNode())
3636
and
3737
(
38-
exists(Return ret, Expr val | ret.getScope() = f.getFunction() and val = ret.getValue() |
38+
exists(Return ret, Expr val | ret.getScope() = f.getScope() and val = ret.getValue() |
3939
meaningful_return_value(val) and
4040
not used_value(val)
4141
)
4242
or
4343
/* Is f a builtin function that returns something other than None?
4444
* Ignore __import__ as it is often called purely for side effects */
45-
f.isC() and f.getAnInferredReturnType() != theNoneType() and not f.getName() = "__import__"
45+
f.isBuiltin() and f.getAnInferredReturnType() != theNoneType() and not f.getName() = "__import__"
4646
)
4747
}
4848

@@ -55,7 +55,7 @@ predicate wrapped_in_try_except(ExprStmt call) {
5555
)
5656
}
5757

58-
from ExprStmt call, FunctionObject callee, float percentage_used, int total
58+
from ExprStmt call, FunctionValue callee, float percentage_used, int total
5959
where call.getValue() = callee.getACall().getNode() and returns_meaningful_value(callee) and
6060
not wrapped_in_try_except(call) and
6161
exists(int unused |

0 commit comments

Comments
 (0)