[cfe-commits] r120144 - /cfe/trunk/lib/Checker/GRExprEngine.cpp

Zhongxing Xu xuzhongxing at gmail.com
Wed Nov 24 22:35:14 PST 2010


Author: zhongxingxu
Date: Thu Nov 25 00:35:14 2010
New Revision: 120144

URL: http://llvm.org/viewvc/llvm-project?rev=120144&view=rev
Log:
For CFGAutomaticObjDtor, the type may be reference type, e.g., const A &c = A();
Also apply some new coding style.

Modified:
    cfe/trunk/lib/Checker/GRExprEngine.cpp

Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=120144&r1=120143&r2=120144&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Thu Nov 25 00:35:14 2010
@@ -738,19 +738,26 @@
   }
 }
 
-void GRExprEngine::ProcessAutomaticObjDtor(const CFGAutomaticObjDtor D,
+void GRExprEngine::ProcessAutomaticObjDtor(const CFGAutomaticObjDtor dtor,
                                            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);
+  ExplodedNode *pred = builder.getBasePredecessor();
+  const GRState *state = pred->getState();
+  const VarDecl *varDecl = dtor.getVarDecl();
+
+  QualType varType = varDecl->getType();
+
+  if (const ReferenceType *refType = varType->getAs<ReferenceType>())
+    varType = refType->getPointeeType();
+
+  const CXXRecordDecl *recordDecl = varType->getAsCXXRecordDecl();
+  assert(recordDecl && "get CXXRecordDecl fail");
+  const CXXDestructorDecl *dtorDecl = recordDecl->getDestructor();
+
+  Loc dest = state->getLValue(varDecl, pred->getLocationContext());
+
+  ExplodedNodeSet dstSet;
+  VisitCXXDestructor(dtorDecl, cast<loc::MemRegionVal>(dest).getRegion(),
+                     dtor.getTriggerStmt(), pred, dstSet);
 }
 
 void GRExprEngine::ProcessBaseDtor(const CFGBaseDtor D,





More information about the cfe-commits mailing list