[PATCH] [StaticAnalyzer]Handle Destructor call generated by C++ delete expr
Jordan Rose
jordan_rose at apple.com
Thu Sep 19 09:18:27 PDT 2013
Almost there. Noticed a number of other spot things I should have reported yesterday. (Sorry!)
================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:583
@@ +582,3 @@
+ CXXRecordDecl *RD = getContext().getBaseElementType(DTy)->getAsCXXRecordDecl();
+ PostImplicitCall PP(RD, DE->getLocStart(), LCtx);
+ NodeBuilder Bldr(Pred, Dst, *currBldrCtx);
----------------
This ought to be the destructor, not the record decl. (Which should be const, BTW.)
It's a little weird because we're /skipping/ the destructor, but still putting a PostImplicitCall node...but I guess we don't have a better alternative.
================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:581
@@ +580,3 @@
+ QualType DTy = DE->getDestroyedType();
+ DTy = DTy.getNonReferenceType();
+ CXXRecordDecl *RD = getContext().getBaseElementType(DTy)->getAsCXXRecordDecl();
----------------
This shouldn't be necessary; the argument to delete is always an rvalue.
================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:575
@@ +574,3 @@
+ const CXXDeleteExpr *DE = Dtor.getDeleteExpr();
+ const Stmt *Arg = cast<Stmt>(DE->getArgument());
+ SVal ArgVal = Pred->getState()->getSVal(Arg, LCtx);
----------------
Just noticed this yesterday: Exprs are Stmts, so this is unnecessary.
================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:577-578
@@ +576,4 @@
+ SVal ArgVal = Pred->getState()->getSVal(Arg, LCtx);
+ // If it is known to be bound to a null value
+ // dont run destructor.
+ if (State->isNull(ArgVal).isConstrainedTrue()) {
----------------
Typo: "dont". Also, it would nice to spell out what "it" is.
================
Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:576
@@ +575,3 @@
+ const Stmt *Arg = cast<Stmt>(DE->getArgument());
+ SVal ArgVal = Pred->getState()->getSVal(Arg, LCtx);
+ // If it is known to be bound to a null value
----------------
And here you already have State in a local variable now.
http://llvm-reviews.chandlerc.com/D1594
More information about the cfe-commits
mailing list