This patch implements the idea discussed on the mailing list, in fact, the included testfile contains the functions example_1 and example_2 exactly how it's described there.
The idea is to, as the title says, to track the value of the condition of the terminator statement on which the reported node depends on:
01 int flag; 02 bool coin(); 03 04 void foo() { 05 flag = coin(); // no note 06 } 07 08 int main() { 09 int *x = 0; // x initialized to 0 10 flag = 1; 11 foo(); 12 if (flag) // assumed false 13 x = new int; 14 foo(); 15 16 if (flag) // assumed true 17 *x = 5; // warn 18 }
We emit a warning at statement 17. The new BugReporter visitor figures out that statement 16 is in fact a control dependency if the reported node, and uses trackExpressionValue() to track it's condition, in this case, flag, resulting in new notes being placed at for the call to foo() on line 14 and a note about flag being invalidated on line 5.
Now, whether this change is any good is practically impossible to tell without evaluation on production code, so I'll get back with that once I gather some data.