]> granicus.if.org Git - clang/commitdiff
When casting VarRegion, if the var type is aggregate type and the cast-to
authorZhongxing Xu <xuzhongxing@gmail.com>
Sat, 9 May 2009 15:34:29 +0000 (15:34 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Sat, 9 May 2009 15:34:29 +0000 (15:34 +0000)
pointee type is scalar type, create element region regardless with the sizes
of types.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71360 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/RegionStore.cpp
test/Analysis/fields.c

index 0fc24a9a2be6e3bcaf386b48b145c9ba79be8255..a66e63c8770fdf0a04b8dbf71d22682423ae7cf3 100644 (file)
@@ -616,7 +616,8 @@ RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R,
     uint64_t PointeeTySize = getContext().getTypeSize(PointeeTy);
     uint64_t ObjTySize = getContext().getTypeSize(ObjTy);
 
-    if (PointeeTySize > 0 && PointeeTySize < ObjTySize) {
+    if ((PointeeTySize > 0 && PointeeTySize < ObjTySize) ||
+        (ObjTy->isAggregateType() && PointeeTy->isScalarType())) {
       // Record the cast type of the region.
       state = setCastType(state, R, ToTy);
 
index 8b88578a0e9f5e41aec5b49766fa4ca89343ece2..c012a9da7b8102e51c807923c303e5039d2f6854 100644 (file)
@@ -1,6 +1,5 @@
 // RUN: clang-cc -analyze -checker-cfref %s --analyzer-store=basic -verify &&
 // RUN: clang-cc -analyze -checker-cfref %s --analyzer-store=region -verify
-// XFAIL
 
 unsigned foo();
 typedef struct bf { unsigned x:2; } bf;