Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13734d4

Browse files
committed
C++: Improve indirectionForModelledFunction.
1 parent 70bb295 commit 13734d4

4 files changed

Lines changed: 18 additions & 28 deletions

File tree

cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,23 @@ module Private {
264264
module Public = Impl::Public;
265265

266266
/**
267-
* Gets the number of indirections that can be returned by the function
268-
* modelled using the given MaD row.
267+
* Gets a number of indirections that can be returned by a function
268+
* modelled using models-as-data.
269269
*/
270-
int indirectionForModelledFunction(
271-
string namespace, string type, boolean subtypes, string name, string signature, string ext,
272-
string input, string output, string kind, string provenance
273-
) {
274-
summaryModel(namespace, type, subtypes, name, signature, ext, input, output, kind, provenance) and
275-
(
276-
// Return the number of stars in `ReturnValue[...]`
277-
result = output.regexpCapture("ReturnValue\\[(\\*+)\\]", 1).length()
278-
or
279-
// There are no brackets the result is 0
280-
output = "ReturnValue" and
281-
result = 0
270+
int returnIndirectionForModelledFunction() {
271+
exists(string inputOutput |
272+
(
273+
sourceModel(_, _, _, _, _, _, inputOutput, _, _) or
274+
sinkModel(_, _, _, _, _, _, inputOutput, _, _) or
275+
summaryModel(_, _, _, _, _, _, inputOutput, _, _, _) or
276+
summaryModel(_, _, _, _, _, _, _, inputOutput, _, _)
277+
) and (
278+
// Return the number of stars in `ReturnValue[...]`
279+
result = inputOutput.regexpCapture("ReturnValue\\[(\\*+)\\]", 1).length()
280+
or
281+
// There are no brackets the result is 0
282+
inputOutput = "ReturnValue" and
283+
result = 0
284+
)
282285
)
283286
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ private newtype TReturnKind =
460460
Ssa::hasIndirectOperand(any(ReturnValueInstruction ret).getReturnAddressOperand(),
461461
indirectionIndex + 1) // We subtract one because the return loads the value.
462462
or
463-
indirectionIndex = FlowSummaryImpl::indirectionForModelledFunction(_, _, _, _, _, _, _, _, _, _)
463+
indirectionIndex = FlowSummaryImpl::returnIndirectionForModelledFunction()
464464
} or
465465
TIndirectReturnKind(int argumentIndex, int indirectionIndex) {
466466
exists(Ssa::FinalParameterUse use |
Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,2 @@
11
testFailures
2-
| sources-and-sinks.cpp:78:20:78:36 | // $ local_source | Missing result:local_source= |
3-
| sources-and-sinks.cpp:79:21:79:37 | // $ local_source | Missing result:local_source= |
4-
| sources-and-sinks.cpp:80:25:80:41 | // $ local_source | Missing result:local_source= |
5-
| sources-and-sinks.cpp:81:28:81:44 | // $ local_source | Missing result:local_source= |
6-
| sources-and-sinks.cpp:82:32:82:48 | // $ local_source | Missing result:local_source= |
7-
| sources-and-sinks.cpp:83:22:83:38 | // $ local_source | Missing result:local_source= |
8-
| sources-and-sinks.cpp:84:26:84:42 | // $ local_source | Missing result:local_source= |
9-
| sources-and-sinks.cpp:85:30:85:46 | // $ local_source | Missing result:local_source= |
10-
| sources-and-sinks.cpp:86:34:86:50 | // $ local_source | Missing result:local_source= |
112
failures
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
testFailures
2-
| sources-and-sinks.cpp:73:25:73:42 | // $ remote_source | Missing result:remote_source= |
3-
| sources-and-sinks.cpp:74:29:74:46 | // $ remote_source | Missing result:remote_source= |
4-
| sources-and-sinks.cpp:75:33:75:50 | // $ remote_source | Missing result:remote_source= |
5-
| sources-and-sinks.cpp:76:37:76:54 | // $ remote_source | Missing result:remote_source= |
62
failures

0 commit comments

Comments
 (0)