mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Make receiver a separate case in TFunctionOutput
This is for consistency with TFunctionInput, which already does this
This commit is contained in:
@@ -139,13 +139,8 @@ private newtype TFunctionOutput =
|
||||
// one among several results
|
||||
exists(SignatureType s | exists(s.getResultType(index)))
|
||||
} or
|
||||
TOutParameter(int index) {
|
||||
// the receiver parameter
|
||||
index = -1
|
||||
or
|
||||
// another parameter
|
||||
exists(SignatureType s | exists(s.getParameterType(index)))
|
||||
}
|
||||
TOutReceiver() or
|
||||
TOutParameter(int index) { exists(SignatureType s | exists(s.getParameterType(index))) }
|
||||
|
||||
/**
|
||||
* An abstract representation of an output of a function, which is one of its results
|
||||
@@ -227,14 +222,32 @@ private class OutResult extends FunctionOutput, TOutResult {
|
||||
}
|
||||
}
|
||||
|
||||
/** A result position of a function, viewed as an output. */
|
||||
private class OutReceiver extends FunctionOutput, TOutReceiver {
|
||||
override predicate isReceiver() { any() }
|
||||
|
||||
override DataFlow::Node getEntryNode(FuncDef f) {
|
||||
// there is no generic way of assigning to a receiver; operations that taint a receiver
|
||||
// have to be handled on a case-by-case basis
|
||||
none()
|
||||
}
|
||||
|
||||
override DataFlow::Node getExitNode(DataFlow::CallNode c) {
|
||||
exists(DataFlow::Node arg |
|
||||
arg = getArgument(c, -1) and
|
||||
result.(DataFlow::PostUpdateNode).getPreUpdateNode() = arg
|
||||
)
|
||||
}
|
||||
|
||||
override string toString() { result = "receiver" }
|
||||
}
|
||||
|
||||
/** A result position of a function, viewed as an output. */
|
||||
private class OutParameter extends FunctionOutput, TOutParameter {
|
||||
int index;
|
||||
|
||||
OutParameter() { this = TOutParameter(index) }
|
||||
|
||||
override predicate isReceiver() { index = -1 }
|
||||
|
||||
override predicate isParameter(int i) { i = index and i >= 0 }
|
||||
|
||||
override DataFlow::Node getEntryNode(FuncDef f) {
|
||||
@@ -250,9 +263,5 @@ private class OutParameter extends FunctionOutput, TOutParameter {
|
||||
)
|
||||
}
|
||||
|
||||
override string toString() {
|
||||
index = -1 and result = "receiver"
|
||||
or
|
||||
index >= 0 and result = "parameter " + index
|
||||
}
|
||||
override string toString() { result = "parameter " + index }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user