aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker/GRExprEngine.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-11-25 06:35:14 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-11-25 06:35:14 +0000
commit2210490e6d099b7a5b4f68f44a136e4dcf3cdea2 (patch)
tree59bba0c37a56b5a2d1504266941bcebdd5be9755 /lib/Checker/GRExprEngine.cpp
parent0e38d5d6775a26f8f39df353e34b0dc14c2d6cfc (diff)
For CFGAutomaticObjDtor, the type may be reference type, e.g., const A &c = A();
Also apply some new coding style. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120144 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/GRExprEngine.cpp')
-rw-r--r--lib/Checker/GRExprEngine.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/Checker/GRExprEngine.cpp b/lib/Checker/GRExprEngine.cpp
index 6db8dbab7d..4121144fad 100644
--- a/lib/Checker/GRExprEngine.cpp
+++ b/lib/Checker/GRExprEngine.cpp
@@ -738,19 +738,26 @@ void GRExprEngine::ProcessImplicitDtor(const CFGImplicitDtor D,
}
}
-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();
+ 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(VD, Pred->getLocationContext());
+ Loc dest = state->getLValue(varDecl, pred->getLocationContext());
- ExplodedNodeSet Dst;
- VisitCXXDestructor(DD, cast<loc::MemRegionVal>(Dest).getRegion(),
- D.getTriggerStmt(), Pred, Dst);
+ ExplodedNodeSet dstSet;
+ VisitCXXDestructor(dtorDecl, cast<loc::MemRegionVal>(dest).getRegion(),
+ dtor.getTriggerStmt(), pred, dstSet);
}
void GRExprEngine::ProcessBaseDtor(const CFGBaseDtor D,