trivial conditions and dataflow solver


I am experimenting with the dataflow solver and am wondering whether the following is expected behavior.

I took a function with a trivially true if condition. When constructing the CFG, clang seems to take this into account and does not generate a successor/predecessor relationship between blocks B1 and B3 (see below). However, when running the dataflow solver, I get that {field3, field2} and {field1} are possible sets of accesses to fields, while I would expect that either {field3,field1} or nothing is reported instead of {field1}. Currently, it seems block B1 is visited and its results are propagated, but it does not receive input values from B3.

Is this the intended behavior? I would expect that blocks without predecessors and that are not entry blocks would be skipped?



Example function:

void func1()


field3 = 5


field2 = 2;


field1 = 2;


A dump of the CFG gives:

[B4 (Entry) ]

Predecessors (0):

Successors (1): B3


1: this->field1 = 2

Predecessors (0);

Successors (1): B0


1: this->field2 = 2




1: this->field3 = 5

2: 1

T: if [B3.2]

Predecessors (1): B4

Successors(2): B2 Null

[B0 (Exit) ]

Predecessors(2):B1 B2


Hi Maarten,

Can you be a bit more specific on what you are doing? Are you using the actual DataflowSolver class? If so, currently ALL blocks are currently enqueued by the solver, not just the roots. IRRC, this was to address an issue that previously existed with the solver and one of the analyses, but now no analyses use the solver anymore this behavior certainly can be changed.

FWIW, I was considering removing this class completely, since it is no longer used.


Hi Ted,

Yes, I am using the DataflowSolver class. Thanks for the heads-up on potential removal of this class. I was under the impression that this was the default Flow Analysis engine, but will look at the current implementation of the analyses to understand alternative options.



There are two dataflow analyses to warn uninitialized values and find live variabels. These two examples are very good tutorials for dataflow analysis.