[cfe-commits] r63347 - in /cfe/trunk: include/clang/Analysis/PathSensitive/BasicValueFactory.h include/clang/Analysis/PathSensitive/MemRegion.h include/clang/Analysis/PathSensitive/SVals.h lib/Analysis/MemRegion.cpp lib/Analysis/RegionStore.cpp l

Ted Kremenek kremenek at apple.com
Thu Jan 29 23:16:51 PST 2009


On Jan 29, 2009, at 8:46 PM, Zhongxing Xu wrote:

>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
> +++ cfe/trunk/lib/Analysis/MemRegion.cpp Thu Jan 29 18:08:43 2009
> @@ -114,8 +114,9 @@
>   if (ArrayType* AT = dyn_cast<ArrayType>(T.getTypePtr()))
>     return AT->getElementType();
>
> -  PointerType* PtrT = cast<PointerType>(T.getTypePtr());
> -  return C.getCanonicalType(PtrT->getPointeeType());
> +  // If the RValueType of the array region isn't an ArrayType, then  
> essentially
> +  // the element's
> +  return T;
>  }
>
> Hi Ted,
>
> This perhaps does not work for code like:
>
> char* p = (char*) alloca(4);
> char* c = p[1];
>
> The array region of element region p[1] is an AnonTypedRegion, whose  
> type is 'pointer to char'.

Hmm.  Just to put a naive suggestion out there: maybe the RValueType  
of this AnonTypeRegion should be 'char' or an 'ArrayType' (since it  
represents chunk of memory).  The RValueType of the region itself  
definitely isn't a char* (but it's LValueType) is.



More information about the cfe-commits mailing list