Skip to content

Commit c9f3ea4

Browse files
author
Owen Jones
committed
Test casts in remove_virtual_function()
Add a test to check that when we replace virtual function calls with static function calls we cast the class to the appropriate type for the static function call, so the argument for the `this` parameter will have the correct type, and also that when a cast is not needed we will not create one. Different code is run if there is only one possible static function or if there is more than one, so we make sure that we test both of these options.
1 parent 8192246 commit c9f3ea4

File tree

6 files changed

+35
-0
lines changed

6 files changed

+35
-0
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
public class VirtualFunctions {
2+
Object static_object;
3+
4+
public static class A {
5+
public void f() {
6+
}
7+
}
8+
9+
public static class B extends A{
10+
public void f() {
11+
}
12+
}
13+
14+
public static class C extends B {
15+
}
16+
17+
public static void check(A a, B b, C c) {
18+
// multiple possibilities, one needs a cast
19+
a.f();
20+
21+
// single possibility, does not need a cast
22+
b.f();
23+
24+
// single possibility, needs cast
25+
c.f();
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
VirtualFunctions.class
3+
--lazy-methods --java-max-vla-length 48 --unwind 8 --java-unwind-enum-static --trace --cover location --function VirtualFunctions.check --show-goto-functions
4+
\(struct VirtualFunctions\$B \*\)a \. VirtualFunctions\$B\.f:\(\)V\(\);$
5+
a \. VirtualFunctions\$A\.f:\(\)V\(\);$
6+
b \. VirtualFunctions\$B\.f:\(\)V\(\);$
7+
\(struct VirtualFunctions\$B \*\)c \. VirtualFunctions\$B\.f:\(\)V\(\);$
8+
--

0 commit comments

Comments
 (0)