<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Yes, that's the general idea, although you should just use isa<CXXNewExpr>(S) for the exceptions instead of checking the statement class directly.</div><div><br></div><div>I'm sure you were already planning this, but please don't commit any major refactoring work without review from Ted, Anna, or me.</div><div><br></div><div>Also, one of the blockers for the original NodeBuilder plan is that you can't iterate over a NodeBuilder and modify it at the same time (because you'll invalidate the set iterators). I don't think we had a planned solution for that.</div><div><br></div><div>Thanks for working on this,</div><div>Jordan</div><div><br></div><br><div><div>On Dec 14, 2012, at 12:20 , Anton Yartsev <<a href="mailto:anton.yartsev@gmail.com">anton.yartsev@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<div text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi, Jordan<br>
<br>
Thanks for the review, added a post-statement callback to
CXXNewExpr and a pre-statement callback to CXXDeleteExpr as
r170234<br>
<br>
I intend to finish the refactoring. The scratch below illustrates
how the code will approximately look like after the refactoring.
Have I got the idea?<br>
<br>
void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,<br>
ExplodedNodeSet &DstTop) {<br>
...<br>
StmtNodeBuilder Bldr(Pred, DstTop, *currBldrCtx);<br>
<br>
// pre checks<br>
Stmt::StmtClass sc = S->getStmtClass();<br>
if (sc != Stmt::CXXNewExprClass && ...) {<br>
ExplodedNodeSet Tmp;<br>
getCheckerManager().runCheckersForPreStmt(Tmp, Pred, C,
*this);<br>
Bldr.takeNodes(Pred);<br>
Bldr.addNodes(Tmp);<br>
}<br>
...<br>
<br>
// visits<br>
switch (S->getStmtClass()) {<br>
...<br>
case Stmt::CompoundAssignOperatorClass:<br>
VisitBinaryOperator(BO, Bldr);<br>
break;<br>
...<br>
}<br>
...<br>
<br>
// post checks<br>
if (sc != Stmt::CXXDeleteExprClass && ...) {<br>
ExplodedNodeSet Tmp;<br>
getCheckerManager().runCheckersForPreStmt(Tmp, DstTop, S,
*this);<br>
Bldr.takeNodes(DstTop);<br>
Bldr.addNodes(Tmp);<br>
}<br>
}<br>
<br>
void ExprEngine::VisitBinaryOperator(const BinaryOperator* B,
StmtNodeBuilder* Bldr);<br>
for (NodeBuilder::iterator i = Bldr.begin(), e = Bldr.end(); i
!= e ; ++i) {<br>
do something;<br>
}<br>
}<br>
</div>
<blockquote cite="mid:44D9094E-D638-4FD0-BBD0-C5972730B9F4@apple.com" type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<div>Hi, Anton. Thanks for looking at this.</div>
<div><br>
</div>
<div>The reason CXXNewExpr does not currently have pre- and post-
statement checks is because it's not clear what a pre-statement
check means. By the time the analyzer reaches the CXXNewExpr,
the constructor for the object has already been run (because the
CXXConstructExpr is a child expression). This is already a
problem for custom allocators (operator new). My plan for this
is to add a new CFG node to represent the allocator call, but I
haven't gotten around to it. You can see the discussion (from
months ago, sadly) in <a moz-do-not-send="true" href="http://llvm.org/bugs/show_bug.cgi?id=12014">PR12014</a>.
There's no real reason for it not to have a post-statement
callback, though.</div>
<div><br>
</div>
<div>What the FIXME was suggesting is not to have individual
pre/post checks in the cases of the Visit method, but to move <i>all</i> the
checks <i>outside</i> the switch statement. The reason <i>this</i> has
been delayed is because we were supposed to switch from passing
around ExplodedNodeSets to passing around NodeBuilders, but even
without that we'd probably still want to be passing in
ExplodedNodeSets rather than a single ExplodedNode predecessor,
and push the loops as far inwards as possible.</div>
<div><br>
</div>
<div>There are a couple of other statements where we deliberately
skipped the pre- or post- statement callback. I think ReturnStmt
is one, since a post-statement check isn't exactly meaningful.
But we can probably special-case those just before calling out
to the CheckerManager.</div>
<div><br>
</div>
<div>So with all that said, if you want to perpetuate the current
state of affairs and add a post-statement callback to CXXNewExpr
and a pre-statement callback to CXXDeleteExpr, that's all right.
(I can guess you're looking at writing some kind of new/delete
checker, which we could really use.) But if you're going for the
full refactoring, let's make sure we get it right.</div>
<div><br>
</div>
<div>Jordan</div>
<div><br>
</div>
<br>
<div>
<div>On Dec 12, 2012, at 18:37 , Anton Yartsev <<a moz-do-not-send="true" href="mailto:anton.yartsev@gmail.com">anton.yartsev@gmail.com</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite">Hi all,<br>
<br>
the patch moves all the [Pre/Post]checks from paticular
VisitSomething() methods to the common Visit() method (the
idea for refactoring came from FIXME notes)<br>
it also makes the analyzer invoke [Pre/Post]Stmt checkers
while processing CXXNewExpr and CXXDeleteExpr (that's what the
patch was originally intended for)<br>
Is it Ok to commit the patch?<br>
<br>
-- <br>
Anton<br>
<br>
<span><movePrePostChecksToVisit.patch></span>_______________________________________________<br>
cfe-commits mailing list<br>
<a moz-do-not-send="true" href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote>
</div>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Anton</pre>
</div>
</blockquote></div><br></body></html>