mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
Python: Get rid of getLiteralValue
This had only two uses in our libraries, so I simply inlined the predicate body in both places.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import python
|
||||
private import LegacyPointsTo
|
||||
private import semmle.python.objects.ObjectInternal
|
||||
|
||||
/** Holds if the comparison `comp` uses `is` or `is not` (represented as `op`) to compare its `left` and `right` arguments. */
|
||||
predicate comparison_using_is(Compare comp, ControlFlowNode left, Cmpop op, ControlFlowNode right) {
|
||||
@@ -121,7 +122,7 @@ predicate invalid_portable_is_comparison(Compare comp, Cmpop op, ClassValue cls)
|
||||
// OK to use 'is' when comparing items from a known set of objects
|
||||
not exists(Expr left, Expr right, Value val |
|
||||
comp.compares(left, op, right) and
|
||||
exists(ImmutableLiteral il | il.getLiteralValue() = val)
|
||||
exists(ImmutableLiteral il | il = val.(ConstantObjectInternal).getLiteral())
|
||||
|
|
||||
left.pointsTo(val) and right.pointsTo(val)
|
||||
or
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
import python
|
||||
import semmle.python.objects.ObjectInternal
|
||||
import semmle.python.strings
|
||||
|
||||
predicate string_format(BinaryExpr operation, StringLiteral str, Value args, AstNode origin) {
|
||||
@@ -31,7 +32,7 @@ int sequence_length(Value args) {
|
||||
not seq.getAnElt() instanceof Starred
|
||||
)
|
||||
or
|
||||
exists(ImmutableLiteral i | i.getLiteralValue() = args | result = 1)
|
||||
exists(ImmutableLiteral i | i = args.(ConstantObjectInternal).getLiteral() | result = 1)
|
||||
}
|
||||
|
||||
from
|
||||
|
||||
Reference in New Issue
Block a user