This patch is part of http://llvm-reviews.chandlerc.com/D2181.
In-class initializers are appended to the CFG when CFGBuilder::addInitializer is called.
Differential D2370
Append CXXDefaultInitExpr's wrapped expression to the CFG when visiting a constructor initializer epertoso on Dec 10 2013, 3:06 AM. Authored by
Details This patch is part of http://llvm-reviews.chandlerc.com/D2181. In-class initializers are appended to the CFG when CFGBuilder::addInitializer is called.
Diff Detail Event TimelineComment Actions This doesn't actually help the analyzer yet: the init expression will be evaluated, but then the result will be thrown away and the old constant-evaluation mechanism will be used instead (see `ExprEngine::Visit`). I'm okay with you not worrying about this for now. I do approve of the comment change, though.
Comment Actions Ah, thanks! But hm...that's not a very good path. We should definitely be allowing edges within the initializer (so we can see that the reason we choose the null pointer path is because a != 1. If you don't want to deal with this right now, you can just add another configuration option to the CFG and have the analyzer currently not include these nodes. I'll take it back out once we've got the analyzer properly handling this as well. Comment Actions Hi, Regarding to events appearing in an in-class initializer expression, we have now two simple approaches: to add an option for the CFG builder (as you suggested), or to let the code remove all the edges excluding those appearing within the expression wrapped by the CXXDefaultInitExpr. Currently (at least until r199843), those events will not be reported (either in Xcode or in the command line). The first approach preserves this behaviour. With the second approach, the output is ambiguous in the presence of multiple constructors. I still prefer to see that warning. If anything more complex than the second approach is required, I'd prefer to keep it separate from this patch and follow the first one. Any suggestions? Comment Actions Yeah, I'm not yet happy with the second approach. Notice how there are still no edges for the in-class initializer of Foo, even though that's clearly an important part of the path that leads to the null dereference. I don't want to block the main part of your patch (improving -Wuninitialized), so let's go with the option for now, and then do it right after. Comment Actions This is fine but it doesn't turn it on for anybody. Unless Richard has any objections, I think it's fine to turn this on for -Wuninitialized, just not for the analyzer. It looks like one good place to do this is in AnalysisManager, which is only used by the analyzer.
Comment Actions This looks good to me. Do you have commit access, or do you need one of us to commit it for you? Comment Actions No, I don't have commit access. Although the tests are passing, I'd still like to clarify the The code in Richard's example doesn't generate a warning. Should it? I could also try to spend another couple of days to see how the |
I would do this using nested ifs but otherwise this looks good.