[PATCH] [StaticAnalyzer]Handle Destructor call generated by C++ delete expr

Karthik Bhat kv.bhat at samsung.com
Mon Sep 16 03:35:23 PDT 2013


  Hi Jordan, Anna,
  Implemented comments from Jordan.

  I think the FIXME comments were a bit misleading. We still do report use after free in this case but at the 1st visible Stmt. We are just skipping the implicit call to destructor in case of delete as there was no Stmt corresponding to it.

  To make it more clear i have added 2 TC's.
  For e.g in testDoubleDeleteClassInstance we still report use of memory after free but it is inside the destructor.

  I do agree here that the destructor should not be modeled when we call delete the second time but as Jordan highlighted currently we do not have a Stmt corresponding to call to destructor in case of delete.

  I'm a bit reserved about calling ReportUseAfterFree with default Range in this case as it would report the warning at incorrect location making it difficult to track the exact point of problem.

  I will try to investigate as Anna suggested if it is possible to add stmt info to destructor in these cases. I think it would simply be same as the deleteExpr which triggered this call. But i would like to address that in a separate revision.

  For now do you think it is ok if we go ahead with commit? I will try to address the issues raised by Anna in next revision ( added a fixme in test case for the same).

  Thanks
  Karthik Bhat

Hi jordan_rose, zaks.anna,

http://llvm-reviews.chandlerc.com/D1594

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D1594?vs=4261&id=4320#toc

Files:
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/NewDelete-checker-test.cpp
  test/Analysis/new.cpp
  include/clang/Analysis/CFG.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1594.6.patch
Type: text/x-patch
Size: 7655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130916/62f4d27d/attachment.bin>


More information about the cfe-commits mailing list