File tree Expand file tree Collapse file tree
lib/semmle/code/cpp/dataflow/internal
test/library-tests/dataflow/models-as-data Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ private import semmle.code.cpp.dataflow.ExternalFlow
1212private import semmle.code.cpp.ir.IR
1313
1414module Input implements InputSig< DataFlowImplSpecific:: CppDataFlow > {
15+ /**
16+ * Gets a string representing a level of indirection, for example for
17+ * `indirection = 2`, the result is `**`.
18+ */
19+ private bindingset [ indirection] string indirectionString ( int indirection ) {
20+ result = concat ( int i | i in [ 1 .. indirection ] | "*" )
21+ }
22+
1523 class SummarizedCallableBase = Function ;
1624
1725 ArgumentPosition callbackSelfParameterPosition ( ) { result = TDirectPosition ( - 1 ) }
@@ -24,8 +32,8 @@ module Input implements InputSig<DataFlowImplSpecific::CppDataFlow> {
2432
2533 string encodeReturn ( ReturnKind rk , string arg ) {
2634 rk != getStandardReturnValueKind ( ) and
27- result = "ReturnValue" and
28- arg = rk . toString ( )
35+ result = indirectionString ( rk . ( NormalReturnKind ) . getIndirectionIndex ( ) ) + "ReturnValue" and
36+ arg = ""
2937 }
3038
3139 string encodeContent ( ContentSet cs , string arg ) {
@@ -34,7 +42,6 @@ module Input implements InputSig<DataFlowImplSpecific::CppDataFlow> {
3442 result = "Field" and
3543 arg = c .getField ( ) .getName ( )
3644 )
37- // TODO: indirection support here?
3845 }
3946
4047 string encodeWithoutContent ( ContentSet c , string arg ) {
Original file line number Diff line number Diff line change 11| tests.cpp:126:5:126:19 | [summary param] 0 in madArg0ToReturn | ParameterNode | madArg0ToReturn | madArg0ToReturn |
22| tests.cpp:126:5:126:19 | [summary] to write: ReturnValue in madArg0ToReturn | ReturnNode | madArg0ToReturn | madArg0ToReturn |
3+ | tests.cpp:127:6:127:28 | [summary param] 0 in madArg0ToReturnIndirect | ParameterNode | madArg0ToReturnIndirect | madArg0ToReturnIndirect |
4+ | tests.cpp:127:6:127:28 | [summary] to write: *ReturnValue in madArg0ToReturnIndirect | ReturnNode | madArg0ToReturnIndirect | madArg0ToReturnIndirect |
35| tests.cpp:129:5:129:28 | [summary param] 0 in madArg0ToReturnValueFlow | ParameterNode | madArg0ToReturnValueFlow | madArg0ToReturnValueFlow |
46| tests.cpp:129:5:129:28 | [summary] to write: ReturnValue in madArg0ToReturnValueFlow | ReturnNode | madArg0ToReturnValueFlow | madArg0ToReturnValueFlow |
57| tests.cpp:220:7:220:19 | [summary param] 0 in madArg0ToSelf | ParameterNode | madArg0ToSelf | madArg0ToSelf |
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ void test_summaries() {
148148 sink (madArg0ToReturn (0 ));
149149 sink (madArg0ToReturn (source ())); // $ ir
150150 sink (*madArg0ToReturnIndirect (0 ));
151- sink (*madArg0ToReturnIndirect (source ())); // $ MISSING: ir
151+ sink (*madArg0ToReturnIndirect (source ())); // $ ir
152152 sink (notASummary (source ()));
153153 sink (madArg0ToReturnValueFlow (0 ));
154154 sink (madArg0ToReturnValueFlow (source ())); // $ ir
You can’t perform that action at this time.
0 commit comments