mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
C++: Tests for cross-target dispatch
This commit is contained in:
@@ -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());
|
||||
}
|
||||
@@ -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 |
|
||||
|
||||
@@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user