From: Zhongxing Xu Date: Thu, 23 Oct 2008 03:10:39 +0000 (+0000) Subject: Let StoreManager do different cast on arrays. BasicStore will just keep it intact. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1911afd2a79cb508bc81b30be49a0c8648a81b0;p=clang Let StoreManager do different cast on arrays. BasicStore will just keep it intact. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58028 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h index 87c180db55..95a439e636 100644 --- a/include/clang/Analysis/PathSensitive/GRState.h +++ b/include/clang/Analysis/PathSensitive/GRState.h @@ -405,6 +405,10 @@ public: return SetSVal(St, Ex, V, isBlkExpr, Invalidate); } + + SVal ArrayToPointer(SVal Array) { + return StoreMgr->ArrayToPointer(Array); + } // Methods that manipulate the GDM. const GRState* addGDM(const GRState* St, void* Key, void* Data); diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h index 5a93e0e5ea..f4f0415863 100644 --- a/include/clang/Analysis/PathSensitive/Store.h +++ b/include/clang/Analysis/PathSensitive/Store.h @@ -61,6 +61,7 @@ public: virtual SVal getLValueElement(const GRState* St, SVal Base, SVal Offset) = 0; + virtual SVal ArrayToPointer(SVal Array) = 0; virtual Store RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live, diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index cdecb19319..70631ac5bf 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -51,6 +51,8 @@ public: SVal getLValueIvar(const GRState* St, const ObjCIvarDecl* D, SVal Base); SVal getLValueField(const GRState* St, SVal Base, const FieldDecl* D); SVal getLValueElement(const GRState* St, SVal Base, SVal Offset); + + SVal ArrayToPointer(SVal Array) { return Array; } virtual Store RemoveDeadBindings(Store store, Stmt* Loc, const LiveVariables& Live, diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index ae474bef61..4d771fb366 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1503,9 +1503,15 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){ MakeNode(Dst, CastE, N, SetSVal(St, CastE, V)); continue; } - + + // StoreManager casts array to different values. + if (ExTy->isArrayType()) { + V = StateMgr.ArrayToPointer(V); + MakeNode(Dst, CastE, N, SetSVal(St, CastE, V)); + continue; + } + // All other cases. - MakeNode(Dst, CastE, N, SetSVal(St, CastE, EvalCast(V, CastE->getType()))); } }