mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Shared: Add a 'getReturnValueKind' predicate and use it in 'interpretOutput' and 'interpretInput' to handle non-standard return value input/output. This is needed to support C++'s ReturnValue[**] notation.
This commit is contained in:
@@ -54,6 +54,20 @@ signature module InputSig<LocationSig Location, DF::InputSig<Location> Lang> {
|
|||||||
/** Gets the return kind corresponding to specification `"ReturnValue"`. */
|
/** Gets the return kind corresponding to specification `"ReturnValue"`. */
|
||||||
Lang::ReturnKind getStandardReturnValueKind();
|
Lang::ReturnKind getStandardReturnValueKind();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the return kind corresponding to specification `"ReturnValue"` when
|
||||||
|
* the supplied argument `arg`.
|
||||||
|
*
|
||||||
|
* Note that it is expected that the following equality holds:
|
||||||
|
* ```
|
||||||
|
* getReturnValueKind("") = getStandardReturnValueKind()
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
default Lang::ReturnKind getReturnValueKind(string arg) {
|
||||||
|
arg = "" and
|
||||||
|
result = getStandardReturnValueKind()
|
||||||
|
}
|
||||||
|
|
||||||
/** Gets the textual representation of parameter position `pos` used in MaD. */
|
/** Gets the textual representation of parameter position `pos` used in MaD. */
|
||||||
string encodeParameterPosition(Lang::ParameterPosition pos);
|
string encodeParameterPosition(Lang::ParameterPosition pos);
|
||||||
|
|
||||||
@@ -2164,9 +2178,15 @@ module Make<
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
c = "ReturnValue" and
|
c.getName() = "ReturnValue" and
|
||||||
node.asNode() =
|
exists(ReturnKind rk |
|
||||||
getAnOutNodeExt(mid.asCall(), TValueReturn(getStandardReturnValueKind()))
|
not exists(c.getAnArgument()) and
|
||||||
|
rk = getStandardReturnValueKind()
|
||||||
|
or
|
||||||
|
rk = getReturnValueKind(c.getAnArgument())
|
||||||
|
|
|
||||||
|
node.asNode() = getAnOutNodeExt(mid.asCall(), TValueReturn(rk))
|
||||||
|
)
|
||||||
or
|
or
|
||||||
SourceSinkInterpretationInput::interpretOutput(c, mid, node)
|
SourceSinkInterpretationInput::interpretOutput(c, mid, node)
|
||||||
)
|
)
|
||||||
@@ -2198,12 +2218,16 @@ module Make<
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
exists(ReturnNode ret, ValueReturnKind kind |
|
exists(ReturnNode ret, ReturnKind kind |
|
||||||
c = "ReturnValue" and
|
c.getName() = "ReturnValue" and
|
||||||
ret = node.asNode() and
|
ret = node.asNode() and
|
||||||
kind.getKind() = ret.getKind() and
|
kind = ret.getKind() and
|
||||||
kind.getKind() = getStandardReturnValueKind() and
|
|
||||||
mid.asCallable() = getNodeEnclosingCallable(ret)
|
mid.asCallable() = getNodeEnclosingCallable(ret)
|
||||||
|
|
|
||||||
|
not exists(c.getAnArgument()) and
|
||||||
|
kind = getStandardReturnValueKind()
|
||||||
|
or
|
||||||
|
kind = getReturnValueKind(c.getAnArgument())
|
||||||
)
|
)
|
||||||
or
|
or
|
||||||
SourceSinkInterpretationInput::interpretInput(c, mid, node)
|
SourceSinkInterpretationInput::interpretInput(c, mid, node)
|
||||||
|
|||||||
Reference in New Issue
Block a user