[cfe-dev] behaviour of EvaluatedExprVisitor vs. StmtVisitor

Ted Kremenek kremenek at apple.com
Tue Aug 16 17:42:16 PDT 2011


On Aug 16, 2011, at 5:17 PM, Caitlin Sadowski wrote:

> Ted,
> 
> Ok, that makes sense.
> 
> Here is my impression: For example,if I want to be sure to visit each
> DeclRefExpr inside of a CFGBlock, I can just iterate over the CFGStmts
> making up the block and use the (nonrecursive) StmtVisitor to visit
> DeclRefExprs (as in the code above). Is this true, or are there any
> corner cases I should be concerned about? I am a bit confused by the
> "AlwaysAdd" vs. "NotAlwaysAdd" enum in AddStmtChoice in CFG.cpp.


Ah, good point.  You have flexibility in how the CFG is constructed.

For the static analyzer, we currently linearize all expressions/statements for the constructed CFG.  That's what I was referring to before.

For the compiler warnings, we only put in a limited subset of the expressions into the CFG, because the current analyses in the frontend  (e.g., -Wuninitialized) only look at some of the expressions, thus putting all expressions in the CFG would make those analyses a bit slower.  DeclRefExprs happen to be one of them that is always in the CFG in both cases.

So, yes, you just need to iterate over CFGStmts in the CFG to find all DeclRefExprs.  You don't even need a StmtVisitor.  Just use a dyn_cast<> on the Stmt*.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110816/53279aa8/attachment.html>


More information about the cfe-dev mailing list