diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-11-25 06:35:14 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-11-25 06:35:14 +0000 |
commit | 16278859e8b71e1f9ddcf075c6df21cfcd0919d9 (patch) | |
tree | 5f44ef4a0255cd0c95237e297b00478ae1abed66 | |
parent | 33f13595c90c69e8e4938200f7777df5930b8880 (diff) | |
download | bcm5719-llvm-16278859e8b71e1f9ddcf075c6df21cfcd0919d9.tar.gz bcm5719-llvm-16278859e8b71e1f9ddcf075c6df21cfcd0919d9.zip |
For CFGAutomaticObjDtor, the type may be reference type, e.g., const A &c = A();
Also apply some new coding style.
llvm-svn: 120144
-rw-r--r-- | clang/lib/Checker/GRExprEngine.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/clang/lib/Checker/GRExprEngine.cpp b/clang/lib/Checker/GRExprEngine.cpp index 6db8dbab7d8..4121144fad2 100644 --- a/clang/lib/Checker/GRExprEngine.cpp +++ b/clang/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, |