Skip to content

Commit 69ea19c

Browse files
committed
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.
1 parent c046a30 commit 69ea19c

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ signature module InputSig<LocationSig Location, DF::InputSig<Location> Lang> {
5454
/** Gets the return kind corresponding to specification `"ReturnValue"`. */
5555
Lang::ReturnKind getStandardReturnValueKind();
5656

57+
/**
58+
* Gets the return kind corresponding to specification `"ReturnValue"` when
59+
* the supplied argument `arg`.
60+
*
61+
* Note that it is expected that the following equality holds:
62+
* ```
63+
* getReturnValueKind("") = getStandardReturnValueKind()
64+
* ```
65+
*/
66+
default Lang::ReturnKind getReturnValueKind(string arg) {
67+
arg = "" and
68+
result = getStandardReturnValueKind()
69+
}
70+
5771
/** Gets the textual representation of parameter position `pos` used in MaD. */
5872
string encodeParameterPosition(Lang::ParameterPosition pos);
5973

@@ -2164,9 +2178,15 @@ module Make<
21642178
)
21652179
)
21662180
or
2167-
c = "ReturnValue" and
2168-
node.asNode() =
2169-
getAnOutNodeExt(mid.asCall(), TValueReturn(getStandardReturnValueKind()))
2181+
c.getName() = "ReturnValue" and
2182+
exists(ReturnKind rk |
2183+
not exists(c.getAnArgument()) and
2184+
rk = getStandardReturnValueKind()
2185+
or
2186+
rk = getReturnValueKind(c.getAnArgument())
2187+
|
2188+
node.asNode() = getAnOutNodeExt(mid.asCall(), TValueReturn(rk))
2189+
)
21702190
or
21712191
SourceSinkInterpretationInput::interpretOutput(c, mid, node)
21722192
)
@@ -2198,12 +2218,16 @@ module Make<
21982218
)
21992219
)
22002220
or
2201-
exists(ReturnNode ret, ValueReturnKind kind |
2202-
c = "ReturnValue" and
2221+
exists(ReturnNode ret, ReturnKind kind |
2222+
c.getName() = "ReturnValue" and
22032223
ret = node.asNode() and
2204-
kind.getKind() = ret.getKind() and
2205-
kind.getKind() = getStandardReturnValueKind() and
2224+
kind = ret.getKind() and
22062225
mid.asCallable() = getNodeEnclosingCallable(ret)
2226+
|
2227+
not exists(c.getAnArgument()) and
2228+
kind = getStandardReturnValueKind()
2229+
or
2230+
kind = getReturnValueKind(c.getAnArgument())
22072231
)
22082232
or
22092233
SourceSinkInterpretationInput::interpretInput(c, mid, node)

0 commit comments

Comments
 (0)
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