C++: Fix off-by-one error in getType on 'FinalGlobalValue' nodes and accept test changes.

This commit is contained in:
Mathias Vorreiter Pedersen
2025-08-19 13:03:53 +02:00
parent 302d35bedc
commit 16508b1800
4 changed files with 7 additions and 5 deletions

View File

@@ -795,7 +795,7 @@ class FinalGlobalValue extends Node, TFinalGlobalValue {
override DataFlowType getType() {
exists(int indirectionIndex |
indirectionIndex = globalUse.getIndirectionIndex() and
result = getTypeImpl(globalUse.getUnderlyingType(), indirectionIndex - 1)
result = getTypeImpl(globalUse.getUnderlyingType(), indirectionIndex)
)
}

View File

@@ -52,10 +52,10 @@ Top *readGlobalBottom() {
}
void DispatchThroughGlobal() {
sink(globalBottom->isSource1()); // $ MISSING: ast,ir
sink(globalBottom->isSource1()); // $ ir MISSING: ast
sink(globalMiddle->isSource1()); // no flow
sink(readGlobalBottom()->isSource1()); // $ MISSING: ast,ir
sink(readGlobalBottom()->isSource1()); // $ ir MISSING: ast
globalBottom = new Bottom();
globalMiddle = new Middle();

View File

@@ -173,6 +173,8 @@ irFlow
| dispatch.cpp:16:37:16:42 | call to source | dispatch.cpp:40:15:40:23 | call to isSource2 |
| dispatch.cpp:22:37:22:42 | call to source | dispatch.cpp:31:16:31:24 | call to isSource1 |
| dispatch.cpp:22:37:22:42 | call to source | dispatch.cpp:39:15:39:23 | call to isSource1 |
| dispatch.cpp:22:37:22:42 | call to source | dispatch.cpp:55:22:55:30 | call to isSource1 |
| dispatch.cpp:22:37:22:42 | call to source | dispatch.cpp:58:28:58:36 | call to isSource1 |
| dispatch.cpp:33:18:33:23 | call to source | dispatch.cpp:23:38:23:38 | x |
| dispatch.cpp:41:17:41:22 | call to source | dispatch.cpp:23:38:23:38 | x |
| dispatch.cpp:69:15:69:20 | call to source | dispatch.cpp:23:38:23:38 | x |

View File

@@ -109,7 +109,7 @@ void set_global_to_derived() {
}
void read_global() {
global_derived->virtual_f(); // $ SPURIOUS: target=3 MISSING: target=8
global_derived->virtual_f(); // $ target=8
}
Base* global_base_or_derived;
@@ -123,5 +123,5 @@ void set_global_base_or_derived_2() {
}
void read_global_base_or_derived() {
global_base_or_derived->virtual_f(); // $ target=3 MISSING: target=8
global_base_or_derived->virtual_f(); // $ target=3 target=8
}