]> granicus.if.org Git - clang/commitdiff
Region store: when casting VarRegions, if the cast-to pointee type is
authorZhongxing Xu <xuzhongxing@gmail.com>
Fri, 8 May 2009 07:28:25 +0000 (07:28 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Fri, 8 May 2009 07:28:25 +0000 (07:28 +0000)
incomplete, do not compute its size and return the original region.

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

lib/Analysis/RegionStore.cpp
test/Analysis/rdar-6541136-region.c

index 32226af98f02b6dd36504c1d56378e18267aebd7..7f103dfab25a1ffb5c72f2476c7de6e378691325 100644 (file)
@@ -668,6 +668,14 @@ RegionStoreManager::CastRegion(const GRState* state, const MemRegion* R,
   // VarRegion.
   if (isa<VarRegion>(R) || isa<ElementRegion>(R) || isa<FieldRegion>(R)
       || isa<ObjCIvarRegion>(R) || isa<CompoundLiteralRegion>(R)) {
+    // If the pointee type is incomplete, do not compute its size, and return
+    // the original region.
+    if (const RecordType *RT = dyn_cast<RecordType>(PointeeTy.getTypePtr())) {
+      const RecordDecl *D = RT->getDecl();
+      if (!D->getDefinition(getContext()))
+        return CastResult(state, R);
+    }
+
     QualType ObjTy = cast<TypedRegion>(R)->getRValueType(getContext());
     uint64_t PointeeTySize = getContext().getTypeSize(PointeeTy);
     uint64_t ObjTySize = getContext().getTypeSize(ObjTy);
index 58ec8e8bbf8bd0708c4c48fefd316b624e632ecc..1e7a2d974bc4d34b0e28dfbc6deb905d16c5bc76 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: clang-cc -verify -analyze -checker-cfref -analyzer-store=region %s
-// XFAIL
 
 struct tea_cheese { unsigned magic; };
 typedef struct tea_cheese kernel_tea_cheese_t;