mirror of
https://github.com/github/codeql.git
synced 2026-05-01 19:55:15 +02:00
Apply review suggestions: use ArgumentNode.argumentOf, and change more uses of ValuePreservingCallable -> ValuePreservingMethod
This commit is contained in:
@@ -46,14 +46,14 @@ abstract class ValuePreservingMethod extends Method {
|
||||
* These steps will be visible for all global data-flow purposes, as well as via
|
||||
* `DataFlow::Node.getASuccessor` and other related functions exposing intraprocedural dataflow.
|
||||
*/
|
||||
abstract class FluentMethod extends ValuePreservingCallable {
|
||||
abstract class FluentMethod extends ValuePreservingMethod {
|
||||
override predicate returnsValue(int arg) { arg = -1 }
|
||||
}
|
||||
|
||||
private class StandardLibraryValuePreservingMethod extends ValuePreservingMethod {
|
||||
int returnsArgNo;
|
||||
|
||||
StandardLibraryValuePreservingCallable() {
|
||||
StandardLibraryValuePreservingMethod() {
|
||||
this.getDeclaringType().hasQualifiedName("java.util", "Objects") and
|
||||
(
|
||||
this.hasName(["requireNonNull", "requireNonNullElseGet"]) and returnsArgNo = 0
|
||||
@@ -63,9 +63,7 @@ private class StandardLibraryValuePreservingMethod extends ValuePreservingMethod
|
||||
this.hasName("toString") and returnsArgNo = 1
|
||||
)
|
||||
or
|
||||
this.getDeclaringType()
|
||||
.getASourceSupertype*()
|
||||
.hasQualifiedName("java.util", "Stack") and
|
||||
this.getDeclaringType().getASourceSupertype*().hasQualifiedName("java.util", "Stack") and
|
||||
this.hasName("push") and
|
||||
returnsArgNo = 0
|
||||
}
|
||||
|
||||
@@ -409,15 +409,11 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
|
||||
or
|
||||
summaryStep(node1, node2, "value")
|
||||
or
|
||||
exists(MethodAccess ma, ValuePreservingCallable c, int argNo |
|
||||
ma.getCallee().getSourceDeclaration() = c and c.returnsValue(argNo)
|
||||
exists(MethodAccess ma, ValuePreservingMethod m, int argNo |
|
||||
ma.getCallee().getSourceDeclaration() = m and m.returnsValue(argNo)
|
||||
|
|
||||
node2.asExpr() = ma and
|
||||
(
|
||||
node1.asExpr() = ma.getArgument(argNo)
|
||||
or
|
||||
argNo = -1 and node1.asExpr() = ma.getQualifier()
|
||||
)
|
||||
node1.(ArgumentNode).argumentOf(ma, argNo)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class Model extends FluentMethod {
|
||||
Model() { this.getName() = "modelledFluentMethod" }
|
||||
}
|
||||
|
||||
class IdentityModel extends ValuePreservingCallable {
|
||||
class IdentityModel extends ValuePreservingMethod {
|
||||
IdentityModel() { this.getName() = "modelledIdentity" }
|
||||
|
||||
override predicate returnsValue(int arg) { arg = 0 }
|
||||
|
||||
Reference in New Issue
Block a user