Skip to content

Shared/C++: Handle non-standard return values in MaD flow sources/sinks #19569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Shared: Add a 'getReturnValueKind' predicate and use it in 'interpret…
…Output' and 'interpretInput' to handle non-standard return value input/output. This is needed to support C++'s ReturnValue[**] notation.
  • Loading branch information
MathiasVP committed May 23, 2025
commit 69ea19cb8b30b8bc61e0961c563fa99b6af6094d
38 changes: 31 additions & 7 deletions shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ signature module InputSig<LocationSig Location, DF::InputSig<Location> Lang> {
/** Gets the return kind corresponding to specification `"ReturnValue"`. */
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. */
string encodeParameterPosition(Lang::ParameterPosition pos);

Expand Down Expand Up @@ -2164,9 +2178,15 @@ module Make<
)
)
or
c = "ReturnValue" and
node.asNode() =
getAnOutNodeExt(mid.asCall(), TValueReturn(getStandardReturnValueKind()))
c.getName() = "ReturnValue" and
exists(ReturnKind rk |
not exists(c.getAnArgument()) and
rk = getStandardReturnValueKind()
or
rk = getReturnValueKind(c.getAnArgument())
|
node.asNode() = getAnOutNodeExt(mid.asCall(), TValueReturn(rk))
)
or
SourceSinkInterpretationInput::interpretOutput(c, mid, node)
)
Expand Down Expand Up @@ -2198,12 +2218,16 @@ module Make<
)
)
or
exists(ReturnNode ret, ValueReturnKind kind |
c = "ReturnValue" and
exists(ReturnNode ret, ReturnKind kind |
c.getName() = "ReturnValue" and
ret = node.asNode() and
kind.getKind() = ret.getKind() and
kind.getKind() = getStandardReturnValueKind() and
kind = ret.getKind() and
mid.asCallable() = getNodeEnclosingCallable(ret)
|
not exists(c.getAnArgument()) and
kind = getStandardReturnValueKind()
or
kind = getReturnValueKind(c.getAnArgument())
)
or
SourceSinkInterpretationInput::interpretInput(c, mid, node)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy