C++: Additional test case for function pointers.

This commit is contained in:
Geoffrey White
2024-04-04 16:26:51 +01:00
parent 144c19db74
commit 49ef677b1d
4 changed files with 16 additions and 4 deletions

View File

@@ -72,3 +72,5 @@
| tests.cpp:422:6:422:25 | [summary] to write: Argument[0].Parameter[0] in madCallArg0WithValue | ArgumentNode | madCallArg0WithValue | madCallArg0WithValue |
| tests.cpp:422:6:422:25 | [summary] to write: Argument[0].Parameter[this] in madCallArg0WithValue | ArgumentNode | madCallArg0WithValue | madCallArg0WithValue |
| tests.cpp:422:6:422:25 | [summary] to write: Argument[1] in madCallArg0WithValue | PostUpdateNode | madCallArg0WithValue | madCallArg0WithValue |
| tests.cpp:423:5:423:36 | [summary param] 1 in madCallReturnValueIgnoreFunction | ParameterNode | madCallReturnValueIgnoreFunction | madCallReturnValueIgnoreFunction |
| tests.cpp:423:5:423:36 | [summary] to write: ReturnValue in madCallReturnValueIgnoreFunction | ReturnNode | madCallReturnValueIgnoreFunction | madCallReturnValueIgnoreFunction |

View File

@@ -28,6 +28,7 @@ summarizedCallables
| tests.cpp:420:5:420:29 | madCallArg0ReturnToReturn |
| tests.cpp:421:9:421:38 | madCallArg0ReturnToReturnFirst |
| tests.cpp:422:6:422:25 | madCallArg0WithValue |
| tests.cpp:423:5:423:36 | madCallReturnValueIgnoreFunction |
sourceCallables
| tests.cpp:3:5:3:10 | source |
| tests.cpp:4:6:4:14 | sourcePtr |
@@ -206,7 +207,11 @@ sourceCallables
| tests.cpp:421:46:421:52 | fun_ptr |
| tests.cpp:422:34:422:40 | fun_ptr |
| tests.cpp:422:53:422:57 | value |
| tests.cpp:424:5:424:14 | getTainted |
| tests.cpp:425:6:425:13 | useValue |
| tests.cpp:425:19:425:19 | x |
| tests.cpp:427:6:427:27 | test_function_pointers |
| tests.cpp:423:45:423:51 | fun_ptr |
| tests.cpp:423:64:423:68 | value |
| tests.cpp:425:5:425:14 | getTainted |
| tests.cpp:426:6:426:13 | useValue |
| tests.cpp:426:19:426:19 | x |
| tests.cpp:427:6:427:17 | dontUseValue |
| tests.cpp:427:23:427:23 | x |
| tests.cpp:429:6:429:27 | test_function_pointers |

View File

@@ -97,6 +97,7 @@ private class TestSummaries extends SummaryModelCsv {
";;false;madCallArg0ReturnToReturn;;;Argument[0].ReturnValue;ReturnValue;value",
";;false;madCallArg0ReturnToReturnFirst;;;Argument[0].ReturnValue;ReturnValue.first;value",
";;false;madCallArg0WithValue;;;Argument[1];Argument[0].Parameter[0];value",
";;false;madCallReturnValueIgnoreFunction;;;Argument[1];ReturnValue;value",
]
}
}

View File

@@ -420,9 +420,11 @@ struct intPair {
int madCallArg0ReturnToReturn(int (*fun_ptr)()); // $ interpretElement
intPair madCallArg0ReturnToReturnFirst(int (*fun_ptr)()); // $ interpretElement
void madCallArg0WithValue(void (*fun_ptr)(int), int value); // $ interpretElement
int madCallReturnValueIgnoreFunction(void (*fun_ptr)(int), int value); // $ interpretElement
int getTainted() { return source(); }
void useValue(int x) { sink(x); }
void dontUseValue(int x) { }
void test_function_pointers() {
sink(madCallArg0ReturnToReturn(&notASource));
@@ -433,4 +435,6 @@ void test_function_pointers() {
madCallArg0WithValue(&useValue, 0);
madCallArg0WithValue(&useValue, source()); // $ MISSING: ir
madCallArg0WithValue(&sink, source()); // $ MISSING: ir
madCallReturnValueIgnoreFunction(&sink, source());
sink(madCallReturnValueIgnoreFunction(&dontUseValue, source())); // $ ir
}