[cfe-commits] r99271 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRExprEngine.h lib/Checker/GRExprEngine.cpp lib/Checker/RegionStore.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Tue Mar 23 02:13:17 PDT 2010
Author: zhongxingxu
Date: Tue Mar 23 04:13:17 2010
New Revision: 99271
URL: http://llvm.org/viewvc/llvm-project?rev=99271&view=rev
Log:
Bind the constructed object value to CXXConstructExpr.
Modified:
cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/lib/Checker/RegionStore.cpp
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h?rev=99271&r1=99270&r2=99271&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h Tue Mar 23 04:13:17 2010
@@ -358,6 +358,10 @@
void CreateCXXTemporaryObject(Expr *Ex, ExplodedNode *Pred,
ExplodedNodeSet &Dst);
+ /// Synthesize CXXThisRegion.
+ const CXXThisRegion *getCXXThisRegion(const CXXConstructExpr *E,
+ const StackFrameContext *SFC);
+
/// EvalEagerlyAssume - Given the nodes in 'Src', eagerly assume symbolic
/// expressions of the form 'x != 0' and generate new nodes (stored in Dst)
/// with those assumptions.
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=99271&r1=99270&r2=99271&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Tue Mar 23 04:13:17 2010
@@ -1333,6 +1333,20 @@
state = state->set<ReturnExpr>(0);
}
+ // Bind the constructed object value to CXXConstructExpr.
+ if (const CXXConstructExpr *CCE = dyn_cast<CXXConstructExpr>(CE)) {
+ const CXXThisRegion *ThisR = getCXXThisRegion(CCE, LocCtx);
+ // We might not have 'this' region in the binding if we didn't inline
+ // the ctor call.
+ SVal ThisV = state->getSVal(ThisR);
+ loc::MemRegionVal *V = dyn_cast<loc::MemRegionVal>(&ThisV);
+ if (V) {
+ SVal ObjVal = state->getSVal(V->getRegion());
+ assert(isa<nonloc::LazyCompoundVal>(ObjVal));
+ state = state->BindExpr(CCE, ObjVal);
+ }
+ }
+
B.GenerateNode(state);
}
@@ -3198,10 +3212,7 @@
Pred->getLocationContext(),
E, Builder->getBlock(), Builder->getIndex());
- Type *T = CD->getParent()->getTypeForDecl();
- QualType PT = getContext().getPointerType(QualType(T,0));
- const CXXThisRegion *ThisR = ValMgr.getRegionManager().getCXXThisRegion(PT,
- SFC);
+ const CXXThisRegion *ThisR = getCXXThisRegion(E, SFC);
CallEnter Loc(E, CD, Pred->getLocationContext());
for (ExplodedNodeSet::iterator NI = ArgsEvaluated.begin(),
@@ -3214,6 +3225,13 @@
Dst.Add(N);
}
}
+
+const CXXThisRegion *GRExprEngine::getCXXThisRegion(const CXXConstructExpr *E,
+ const StackFrameContext *SFC) {
+ Type *T = E->getConstructor()->getParent()->getTypeForDecl();
+ QualType PT = getContext().getPointerType(QualType(T,0));
+ return ValMgr.getRegionManager().getCXXThisRegion(PT, SFC);
+}
//===----------------------------------------------------------------------===//
// Checker registration/lookup.
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=99271&r1=99270&r2=99271&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Tue Mar 23 04:13:17 2010
@@ -1044,7 +1044,7 @@
}
#endif
- if (RTy->isStructureType())
+ if (RTy->isStructureType() || RTy->isClassType())
return RetrieveStruct(store, R);
// FIXME: Handle unions.
@@ -1337,8 +1337,7 @@
SVal RegionStoreManager::RetrieveStruct(Store store, const TypedRegion* R) {
QualType T = R->getValueType(getContext());
- assert(T->isStructureType());
- assert(T->getAsStructureType()->getDecl()->isDefinition());
+ assert(T->isStructureType() || T->isClassType());
return ValMgr.makeLazyCompoundVal(store, R);
}
More information about the cfe-commits
mailing list