[cfe-commits] r60995 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicObjCFoundationChecks.cpp lib/Analysis/BasicStore.cpp lib/Analysis/CFRefCount.cpp lib/Analysis/GR

Zhongxing Xu xuzhongxing at gmail.com
Sat Dec 13 19:30:47 PST 2008


>
>
> @@ -378,25 +381,22 @@
>   return loc::MemRegionVal(ER);
>  }
>
> -std::pair<const GRState*, SVal>
> -RegionStoreManager::CastRegion(const GRState* St, SVal VoidPtr,
> -                               QualType CastToTy, Stmt* CastE) {
> -  if (const AllocaRegion* AR =
> -
>  dyn_cast<AllocaRegion>(cast<loc::MemRegionVal>(VoidPtr).getRegion())) {
> -
> -    // Create a new region to attach type information to it.
> -    const AnonTypedRegion* TR = MRMgr.getAnonTypedRegion(CastToTy, AR);
> -
> -    // Get the pointer to the first element.
> -    nonloc::ConcreteInt Idx(getBasicVals().getZeroWithPtrWidth(false));
> -    const ElementRegion* ER = MRMgr.getElementRegion(Idx, TR);
> -
> -    // Add a RegionView to base region.
> -    return std::make_pair(AddRegionView(St, TR, AR),
> loc::MemRegionVal(ER));
> +StoreManager::CastResult
> +RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R,
> +                               QualType CastToTy) {
> +
> +  // Return the same region if the region types are compatible.
> +  if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) {
> +    ASTContext& Ctx = StateMgr.getContext();
> +    QualType Ta = Ctx.getCanonicalType(TR->getLValueType(Ctx));
> +    QualType Tb = Ctx.getCanonicalType(CastToTy);
> +
> +    if (Ta == Tb)
> +      return CastResult(state, R);
>   }
> -
> -  // Default case.
> -  return std::make_pair(St, UnknownVal());
> +
> +  const MemRegion* ViewR = MRMgr.getAnonTypedRegion(CastToTy, R);
> +  return CastResult(AddRegionView(state, ViewR, R), ViewR);
>  }
>

Hi Ted,

Here we still wish to return an ElementRegion instead of a raw
AnonTypedRegion. Consider this code:

char* p = alloca(10); // after this expression, p is expected to be a
pointer to the first element of the array.
p[0] = 'a';

p is expected to have ElementRegion location value in
RegionStoreManager::getLValueElement().
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20081214/253246a6/attachment.html>


More information about the cfe-commits mailing list