Skip to content

Commit 5ccc12c

Browse files
committed
C++: Add a testcase that demonstrates the problem with MaD and typedefs.
1 parent f23e56b commit 5ccc12c

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

cpp/ql/test/library-tests/dataflow/models-as-data/SummaryCall.expected

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,15 @@ sourceCallables
218218
| tests.cpp:441:6:441:17 | dontUseValue |
219219
| tests.cpp:441:23:441:23 | x |
220220
| tests.cpp:443:6:443:27 | test_function_pointers |
221+
| tests.cpp:456:19:456:19 | X |
222+
| tests.cpp:457:8:457:35 | StructWithTypedefInParameter<X> |
223+
| tests.cpp:457:8:457:35 | StructWithTypedefInParameter<int> |
224+
| tests.cpp:458:12:458:15 | Type |
225+
| tests.cpp:459:5:459:31 | parameter_ref_to_return_ref |
226+
| tests.cpp:459:5:459:31 | parameter_ref_to_return_ref |
227+
| tests.cpp:459:45:459:45 | x |
228+
| tests.cpp:459:45:459:45 | x |
229+
| tests.cpp:462:6:462:37 | test_parameter_ref_to_return_ref |
230+
| tests.cpp:463:6:463:6 | x |
231+
| tests.cpp:464:36:464:36 | s |
232+
| tests.cpp:465:6:465:6 | y |

cpp/ql/test/library-tests/dataflow/models-as-data/testModels.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ private class TestSummaries extends SummaryModelCsv {
9898
";;false;madCallArg0ReturnToReturnFirst;;;Argument[0].ReturnValue;ReturnValue.Field[first];value",
9999
";;false;madCallArg0WithValue;;;Argument[1];Argument[0].Parameter[0];value",
100100
";;false;madCallReturnValueIgnoreFunction;;;Argument[1];ReturnValue;value",
101+
";StructWithTypedefInParameter<T>;true;parameter_ref_to_return_ref;(const T &);;Argument[*0];ReturnValue[*];value"
101102
]
102103
}
103104
}

cpp/ql/test/library-tests/dataflow/models-as-data/tests.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,3 +452,16 @@ void test_function_pointers() {
452452
madCallReturnValueIgnoreFunction(&sink, source());
453453
sink(madCallReturnValueIgnoreFunction(&dontUseValue, source())); // $ ir
454454
}
455+
456+
template<typename X>
457+
struct StructWithTypedefInParameter {
458+
typedef X Type;
459+
X& parameter_ref_to_return_ref(const Type& x); // $ MISSING: interpretElement
460+
};
461+
462+
void test_parameter_ref_to_return_ref() {
463+
int x = source();
464+
StructWithTypedefInParameter<int> s;
465+
int y = s.parameter_ref_to_return_ref(x);
466+
sink(y); // $ MISSING: ir
467+
}

0 commit comments

Comments
 (0)