<br><br><div class="gmail_quote">On Sun, Nov 16, 2008 at 1:21 PM, Ted Kremenek <span dir="ltr"><<a href="mailto:kremenek@apple.com">kremenek@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d"><br>
On Nov 15, 2008, at 8:07 PM, Zhongxing Xu wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
+const GRState* RegionStoreManager::CastRegion(const GRState* St,<br>
+                                              SVal VoidPtr,<br>
+                                              QualType CastToTy,<br>
+                                              Stmt* CastE) {<br>
+  if (const AllocaRegion* AR =<br>
+      dyn_cast<AllocaRegion>(cast<loc::MemRegionVal>(VoidPtr).getRegion())) {<br>
+<br>
+    // Create a new region to attach type information to it.<br>
+    const AnonTypedRegion* TR = MRMgr.getAnonTypedRegion(CastToTy, AR);<br>
+<br>
+    // Get the pointer to the first element.<br>
+    nonloc::ConcreteInt Idx(getBasicVals().getZeroWithPtrWidth(false));<br>
+    const ElementRegion* ER = MRMgr.getElementRegion(Idx, TR);<br>
+<br>
+    St = StateMgr.BindExpr(St, CastE, loc::MemRegionVal(ER));<br>
+<br>
</blockquote>
<br></div>
I'm thinking that we should not assume that CastRegion will be used only in EvalCast.  More specifically, StoreManager should never modify the environment (i.e., call BindExpr), since that violates the encapsulation between StoreManager and the rest of GRState.<br>

<br>
A simple solution is return a std::pair of the new state and the new region, and have GRExprEngine do the actual call to BindExpr.<br>
</blockquote></div><br>That's a good idea. I'll take care it.<br>