[cfe-commits] r74406 - /cfe/trunk/lib/Analysis/BasicStore.cpp

Ted Kremenek kremenek at apple.com
Tue Jun 30 12:49:55 PDT 2009


Great cleanup!

On Jun 28, 2009, at 2:26 AM, Zhongxing Xu wrote:

> Author: zhongxingxu
> Date: Sun Jun 28 04:26:15 2009
> New Revision: 74406
>
> URL: http://llvm.org/viewvc/llvm-project?rev=74406&view=rev
> Log:
> Simplify some code. As in region store, we always expect the  
> location is a
> memregion.
>
> Modified:
>    cfe/trunk/lib/Analysis/BasicStore.cpp
>
> Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=74406&r1=74405&r2=74406&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
> +++ cfe/trunk/lib/Analysis/BasicStore.cpp Sun Jun 28 04:26:15 2009
> @@ -319,54 +319,47 @@
> }
>
> Store BasicStoreManager::BindInternal(Store store, Loc loc, SVal V) {
> -  switch (loc.getSubKind()) {
> -    case loc::MemRegionKind: {
> -      const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion();
> -      ASTContext &C = StateMgr.getContext();
> +  const MemRegion* R = cast<loc::MemRegionVal>(loc).getRegion();
> +  ASTContext &C = StateMgr.getContext();
>
> -      // Special case: handle store of pointer values (Loc) to  
> pointers via
> -      // a cast to intXX_t*, void*, etc.  This is needed to handle
> -      // OSCompareAndSwap32Barrier/OSCompareAndSwap64Barrier.
> -      if (isa<Loc>(V) || isa<nonloc::LocAsInteger>(V))
> -        if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
> -          // FIXME: Should check for index 0.
> -          QualType T = ER->getLocationType(C);
> +  // Special case: handle store of pointer values (Loc) to pointers  
> via
> +  // a cast to intXX_t*, void*, etc.  This is needed to handle
> +  // OSCompareAndSwap32Barrier/OSCompareAndSwap64Barrier.
> +  if (isa<Loc>(V) || isa<nonloc::LocAsInteger>(V))
> +    if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) {
> +      // FIXME: Should check for index 0.
> +      QualType T = ER->getLocationType(C);
>
> -          if (isHigherOrderRawPtr(T, C))
> -            R = ER->getSuperRegion();
> -        }
> +      if (isHigherOrderRawPtr(T, C))
> +        R = ER->getSuperRegion();
> +    }
>
> -      if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
> -        return store;
> +  if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
> +    return store;
>
> -      // We only track bindings to self.ivar.
> -      if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R))
> -        if (IVR->getSuperRegion() != SelfRegion)
> -          return store;
> +  // We only track bindings to self.ivar.
> +  if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R))
> +    if (IVR->getSuperRegion() != SelfRegion)
> +      return store;
>
> -      if (nonloc::LocAsInteger *X = dyn_cast<nonloc::LocAsInteger> 
> (&V)) {
> -        // Only convert 'V' to a location iff the underlying region  
> type
> -        // is a location as well.
> -        // FIXME: We are allowing a store of an arbitrary location to
> -        // a pointer.  We may wish to flag a type error here if the  
> types
> -        // are incompatible.  This may also cause lots of breakage
> -        // elsewhere. Food for thought.
> -        if (const TypedRegion *TyR = dyn_cast<TypedRegion>(R)) {
> -          if (TyR->isBoundable() &&
> -              Loc::IsLocType(TyR->getValueType(C)))
> -            V = X->getLoc();
> -        }
> -      }
> -
> -      BindingsTy B = GetBindings(store);
> -      return V.isUnknown()
> -        ? VBFactory.Remove(B, R).getRoot()
> -        : VBFactory.Add(B, R, V).getRoot();
> +  if (nonloc::LocAsInteger *X = dyn_cast<nonloc::LocAsInteger>(&V)) {
> +    // Only convert 'V' to a location iff the underlying region type
> +    // is a location as well.
> +    // FIXME: We are allowing a store of an arbitrary location to
> +    // a pointer.  We may wish to flag a type error here if the types
> +    // are incompatible.  This may also cause lots of breakage
> +    // elsewhere. Food for thought.
> +    if (const TypedRegion *TyR = dyn_cast<TypedRegion>(R)) {
> +      if (TyR->isBoundable() &&
> +          Loc::IsLocType(TyR->getValueType(C)))
> +        V = X->getLoc();
>     }
> -    default:
> -      assert ("SetSVal for given Loc type not yet implemented.");
> -      return store;
>   }
> +
> +  BindingsTy B = GetBindings(store);
> +  return V.isUnknown()
> +    ? VBFactory.Remove(B, R).getRoot()
> +    : VBFactory.Add(B, R, V).getRoot();
> }
>
> Store BasicStoreManager::Remove(Store store, Loc loc) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list