Handle CFGAutomaticObjDtor. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119897 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Checker/GRCXXExprEngine.cpp b/lib/Checker/GRCXXExprEngine.cpp
index 642c26e..ecc1490 100644
--- a/lib/Checker/GRCXXExprEngine.cpp
+++ b/lib/Checker/GRCXXExprEngine.cpp
@@ -143,6 +143,30 @@
   }
 }
 
+void GRExprEngine::VisitCXXDestructor(const CXXDestructorDecl *DD,
+                                      const MemRegion *Dest,
+                                      const Stmt *S,
+                                      ExplodedNode *Pred, 
+                                      ExplodedNodeSet &Dst) {
+  if (!(DD->isThisDeclarationADefinition() && AMgr.shouldInlineCall()))
+    return;
+  // Create the context for 'this' region.
+  const StackFrameContext *SFC = AMgr.getStackFrame(DD,
+                                                    Pred->getLocationContext(),
+                                                    S, Builder->getBlock(),
+                                                    Builder->getIndex());
+
+  const CXXThisRegion *ThisR = getCXXThisRegion(DD->getParent(), SFC);
+
+  CallEnter PP(S, SFC->getAnalysisContext(), Pred->getLocationContext());
+
+  const GRState *state = Pred->getState();
+  state = state->bindLoc(loc::MemRegionVal(ThisR), loc::MemRegionVal(Dest));
+  ExplodedNode *N = Builder->generateNode(PP, state, Pred);
+  if (N)
+    Dst.Add(N);
+}
+
 void GRExprEngine::VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE, 
                                           ExplodedNode *Pred, 
                                           ExplodedNodeSet &Dst) {
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index ddd3d50..4483cdb 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -718,6 +718,8 @@
 
 void GRExprEngine::ProcessImplicitDtor(const CFGImplicitDtor D,
                                        GRStmtNodeBuilder &builder) {
+  Builder = &builder;
+
   switch (D.getDtorKind()) {
   case CFGElement::AutomaticObjectDtor:
     ProcessAutomaticObjDtor(cast<CFGAutomaticObjDtor>(D), builder);
@@ -738,6 +740,17 @@
 
 void GRExprEngine::ProcessAutomaticObjDtor(const CFGAutomaticObjDtor D,
                                            GRStmtNodeBuilder &builder) {
+  ExplodedNode *Pred = builder.getBasePredecessor();
+  const GRState *state = Pred->getState();
+  const VarDecl *VD = D.getVarDecl();
+  const CXXRecordDecl *CD = VD->getType()->getAsCXXRecordDecl();
+  const CXXDestructorDecl *DD = CD->getDestructor();
+
+  Loc Dest = state->getLValue(VD, Pred->getLocationContext());
+
+  ExplodedNodeSet Dst;
+  VisitCXXDestructor(DD, cast<loc::MemRegionVal>(Dest).getRegion(),
+                     D.getTriggerStmt(), Pred, Dst);
 }
 
 void GRExprEngine::ProcessBaseDtor(const CFGBaseDtor D,
diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp
index 7808872..144c925 100644
--- a/lib/Checker/RegionStore.cpp
+++ b/lib/Checker/RegionStore.cpp
@@ -1828,7 +1828,7 @@
       store = Bind(store, ValMgr.makeLoc(MRMgr.getVarRegion(*PI,frame)),ArgVal);
     }
   } else
-    llvm_unreachable("Unhandled call expression.");
+    assert(isa<CXXDestructorDecl>(frame->getDecl()));
 
   return store;
 }