Data-Flow Analysis

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:

dVariable is defined and set
rVariable is referenced
uVariable 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

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:

Mindr, rr
Maxdr, dd
Helperur, 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;
    }
}