C++: Tests for cross-target dispatch

This commit is contained in:
Jonas Jensen
2019-03-05 15:56:53 +01:00
parent 14f1ecb456
commit 10ce13d1e9
3 changed files with 44 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
int source();
void sink(int);
// For the purpose of this test, this function acts like it's defined in a
// different link target such that we get two different functions named
// `calleeAcrossLinkTargets` and no link from the caller to this one. The test
// is getting that effect because the library can't distinguish the two
// overloaded functions that differ only on `int` vs. `long`, so we might lose
// this result and be forced to write a better test if the function signature
// detection should improve.
void calleeAcrossLinkTargets(long x) {
sink(x);
}
void calleeAcrossLinkTargets(int x); // no body
void callerAcrossLinkTargets() {
calleeAcrossLinkTargets(source());
}
///////////////////////////////////////////////////////////////////////////////
// No flow into this function as its signature is not unique (in the limited
// model of the library).
void ambiguousCallee(long x) {
sink(x);
}
// No flow into this function as its signature is not unique (in the limited
// model of the library).
void ambiguousCallee(short x) {
sink(x);
}
void ambiguousCallee(int x); // no body
void ambiguousCaller() {
ambiguousCallee(source());
}

View File

@@ -1,3 +1,4 @@
| acrossLinkTargets.cpp:12:8:12:8 | x | acrossLinkTargets.cpp:19:27:19:32 | call to source |
| test.cpp:7:8:7:9 | t1 | test.cpp:6:12:6:17 | call to source |
| test.cpp:9:8:9:9 | t1 | test.cpp:6:12:6:17 | call to source |
| test.cpp:10:8:10:9 | t2 | test.cpp:6:12:6:17 | call to source |

View File

@@ -1,3 +1,4 @@
| acrossLinkTargets.cpp:19:27:19:32 | acrossLinkTargets.cpp:12:8:12:8 | AST only |
| test.cpp:66:30:66:36 | test.cpp:71:8:71:9 | AST only |
| test.cpp:89:28:89:34 | test.cpp:92:8:92:14 | IR only |
| test.cpp:100:13:100:18 | test.cpp:103:10:103:12 | AST only |