I am trying to create a simple tool to detect the use of uninitialized variables based on Clang AST. What I know is that the thing actually causes UB with uninit variables is an lvalue to rvalue cast that happens implicitly.
Now what I noticed while examining the AST of a basic example program is that all compound assignment operators do not cause any such cast node to appear! Does this imply that no UB takes place?
int a;
int b = 10;
b += a; // this line is obviously UB...
a += b; // ... but is this one ok?
// Note: no ImplicitCastExpr of LvalueToRvalue type in AST !
That is also true for postfix / prefix increment / decrement operators (in particular, I have absolutely no clue how postfix operators save the 'value' of the variable without copying).
I managed to find some info about increment operators (Is it legal to increment non-initialized variable? - only one reference, unfortunately), but now struggle with comp. assignments. If possible, I'd love to know in particular what happens to increment as well.