[cfe-dev] CFG and CXXDefaultInitExpr

Jordan Rose jordan_rose at apple.com
Fri Oct 18 09:40:25 PDT 2013


Unfortunately yes: a CXXDefaultInitExpr is a placeholder for whichever expression was written as the initial value of the member you've left out, and that expression doesn't belong to the current context. If you used list initialization (braces) to initialize two different objects, you'd end up including the initializer expression twice, and the CFG doesn't work right if the same Stmt* appears more than once.

That said, I would think that the presence of a CXXDefaultInitExpr would be enough to prove that a member variable is initialized. If you're worried about initialization order problems, you could either traverse the CXXDefaultInitExpr manually or just make a non-flow-sensitive check that the initializer expression doesn't reference any member variables defined later in the class.

Does that help?
Jordan


On Oct 18, 2013, at 9:19 , Enrico P <epertoso at google.com> wrote:

> Hello,
> 
> I'm doing some work on -Wuninitialized to make it detect the use of uninitialized fields within C++ constructor bodies.
> 
> When the CFGBuilder visits a CXXDefaultInitExpr, it won't visit its children because CXXDefaultInitExpr::children() returns an empty child_range.
> 
> Is there any reason for this (maybe related to the comment at line 1108 of CFG.cpp?), or is it safe to have it return a non-empty child_range?
> 
> Thanks,
> Enrico
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list