The Data Flow Analysis requires a Control-Flow Analysis (precondition). The data-flow for a variable within a program path (class or method) is defined through the following actions:
d | Variable is defined and set |
r | Variable is referenced |
u | Variable is undefined |
Valid combinations are:
- dr, rr
no anomalies. - dd, du
decent anomalies. - ur
critical anomalies.
Advantages
- Is equal to intuitive developer tests
- Anomalies of error-prone program sequences can be easily identified
- Indicates, which source code location must be checked
- Evaluation in combination with compiler warnings shall be considered
Disadvantages
- Decent anomalies, identified by the Control Flow result in warnings and hints. They do not create external failures.
Example
Given the following error-prone pseudo code:
sort (int Min, int Max) {
int Helper;
if (Min > Max) {
Max = Helper;
Max = Min;
Helper = Min;
}
}
The example above provides the following characteristics regarding anomalies:
Min | dr, rr |
Max | dr, dd |
Helper | ur, du |
The correct pseudocode must look liked illustrated below:
sort (int Min, int Max) {
int Helper;
if (Min > Max) {
Helper = Max;
Max = Min;
Min = Helper;
}
}