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

Jordan Rose jordan_rose at apple.com
Fri Sep 6 17:19:02 PDT 2013


  Ah, right. Two types in tests makes sense. (There are ways around it but this is simple enough.)

  Main comment is about handling null; other than that this is looking good. I'm not sure you'll be able to easily test the null-handling, either...perhaps something reinterpret_cast'ed into a NoReturnDtor *?

  Also, nitpick: it'd be nice if the tests followed LLVM formatting as well.


================
Comment at: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp:303-309
@@ -302,1 +302,9 @@
 
+  // If the memory region to be invalidated is null do not call the
+  // destructors. Return a node with state same as previous node.
+  if (!Dest) {
+    StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
+    Bldr.generateNode(S, Pred, State);
+    return;
+  }
+  
----------------
This isn't quite right either -- DestVal could easily be Unknown, or (in theory, anyway) a SymbolicRegion whose symbol is known to be 0. I think you actually have to check here -- ProgramState::isNull is probably what you want...or even a proper assume(), since if we do run the destructor we "know" the region was not null.


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



More information about the cfe-commits mailing list