summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2008-10-21 06:54:23 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2008-10-21 06:54:23 +0000
commitdab76fd8227dae3aa8db070b3cfd212361757c64 (patch)
treed03e3c18c5fac07caa3b03b4949740c2af1ec24f
parent8f6855e64219846070cdc41da74d795712788206 (diff)
downloadbcm5719-llvm-dab76fd8227dae3aa8db070b3cfd212361757c64.tar.gz
bcm5719-llvm-dab76fd8227dae3aa8db070b3cfd212361757c64.zip
Localize the special processing of array variable inside
GRExprEngine::VisitCast() so that other parts of the analyzer can be ignorant. When we cast "array of type T" to "pointer to T", we get the loc::MemRegionVal corresponding to the array variable. This is sufficient for BasicStore, but not for RegionStore. RegionStore should get the element region for the first array element in the cast. So next comes to the revamping of transfer functions for different store model. llvm-svn: 57897
-rw-r--r--clang/lib/Analysis/BasicStore.cpp1
-rw-r--r--clang/lib/Analysis/GRExprEngine.cpp16
2 files changed, 3 insertions, 14 deletions
diff --git a/clang/lib/Analysis/BasicStore.cpp b/clang/lib/Analysis/BasicStore.cpp
index c37db366406..b42f210dd83 100644
--- a/clang/lib/Analysis/BasicStore.cpp
+++ b/clang/lib/Analysis/BasicStore.cpp
@@ -78,6 +78,7 @@ public:
StoreManager* clang::CreateBasicStoreManager(GRStateManager& StMgr) {
return new BasicStoreManager(StMgr);
}
+
SVal BasicStoreManager::getLValueVar(const GRState* St, const VarDecl* VD) {
return loc::MemRegionVal(MRMgr.getVarRegion(VD));
}
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp
index 32c83669e32..68f10b0d038 100644
--- a/clang/lib/Analysis/GRExprEngine.cpp
+++ b/clang/lib/Analysis/GRExprEngine.cpp
@@ -829,17 +829,6 @@ void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* Ex, NodeTy* Pred, NodeSet& Dst,
SVal V = StateMgr.GetLValue(St, VD);
- if (VD->getType()->isArrayType()) {
- // C++ standard says array of type T should be implicitly converted to
- // pointer to type T in some cases. Currently we don't do this cast in
- // VisitCast(), because BasicStore is not field sensitive. We shall do
- // this in a transfer function in the future. We represent both lvalue and
- // rvalue of array of type T as the corresponding MemRegionVal of it.
-
- MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, V));
- return;
- }
-
if (asLValue)
MakeNode(Dst, Ex, Pred, SetSVal(St, Ex, V));
else
@@ -1445,8 +1434,9 @@ void GRExprEngine::VisitObjCMessageExprDispatchHelper(ObjCMessageExpr* ME,
void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
NodeSet S1;
QualType T = CastE->getType();
+ QualType ExTy = Ex->getType();
- if (T->isReferenceType())
+ if (ExTy->isArrayType() || T->isReferenceType())
VisitLValue(Ex, Pred, S1);
else
Visit(Ex, Pred, S1);
@@ -1464,8 +1454,6 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){
// let the transfer function object be responsible for constructing
// nodes.
- QualType ExTy = Ex->getType();
-
for (NodeSet::iterator I1 = S1.begin(), E1 = S1.end(); I1 != E1; ++I1) {
NodeTy* N = *I1;
const GRState* St = GetState(N);
OpenPOWER on IntegriCloud