Skip to content

Commit ea3bb8c

Browse files
committed
Shared: Provide a hook to MaD generation to modify the 'ReturnValue' string.
1 parent 6c348b5 commit ea3bb8c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

shared/mad/codeql/mad/modelgenerator/internal/ModelGeneratorImpl.qll

+13-3
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ signature module ModelGeneratorInputSig<LocationSig Location, InputSig<Location>
222222
*/
223223
default Lang::ParameterPosition getReturnKindParamPosition(Lang::ReturnKind node) { none() }
224224

225+
/**
226+
* Gets the string that represents the return value corresponding to the
227+
* return kind `kind`.
228+
*
229+
* For most languages this will be the string "ReturnValue".
230+
*/
231+
default string getReturnValueString(Lang::ReturnKind kind) { result = "ReturnValue" }
232+
225233
/**
226234
* Holds if it is irrelevant to generate models for `api` based on data flow analysis.
227235
*
@@ -317,9 +325,11 @@ module MakeModelGenerator<
317325

318326
private module PrintReturnNodeExt<printCallableParamSig/2 printCallableParam> {
319327
string getOutput(ReturnNodeExt node) {
320-
node.getKind() instanceof DataFlow::ValueReturnKind and
321-
not exists(node.getPosition()) and
322-
result = "ReturnValue"
328+
exists(DataFlow::ValueReturnKind valueReturnKind |
329+
valueReturnKind = node.getKind() and
330+
not exists(node.getPosition()) and
331+
result = getReturnValueString(valueReturnKind.getKind())
332+
)
323333
or
324334
exists(DataFlow::ParameterPosition pos |
325335
pos = node.getPosition() and

0 commit comments

Comments
 (0)