[cfe-commits] r82492 - in /cfe/trunk: lib/Analysis/RegionStore.cpp test/Analysis/misc-ps-region-store.m

Ted Kremenek kremenek at apple.com
Mon Sep 21 15:58:52 PDT 2009


Author: kremenek
Date: Mon Sep 21 17:58:52 2009
New Revision: 82492

URL: http://llvm.org/viewvc/llvm-project?rev=82492&view=rev
Log:
Provide intermediate solution to handling assignments to structs via an
integer pointer.  For now just invalidate the fields of the struct.

This addresses: <rdar://problem/7185607> [RegionStore] support invalidation of bit fields using integer assignment


Modified:
    cfe/trunk/lib/Analysis/RegionStore.cpp
    cfe/trunk/test/Analysis/misc-ps-region-store.m

Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=82492&r1=82491&r2=82492&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Mon Sep 21 17:58:52 2009
@@ -1302,6 +1302,10 @@
             ValMgr.getSValuator().EvalCast(V, state, superTy, erTy);
           return Bind(cr.getState(), loc::MemRegionVal(superR), cr.getSVal());
         }
+        // For now, just invalidate the fields of the struct/union/class.
+        // FIXME: Precisely handle the fields of the record.
+        if (superTy->isRecordType())
+          return InvalidateRegion(state, superR, NULL, 0);
       }
     }
   }

Modified: cfe/trunk/test/Analysis/misc-ps-region-store.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.m?rev=82492&r1=82491&r2=82492&view=diff

==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.m Mon Sep 21 17:58:52 2009
@@ -167,3 +167,18 @@
     *q = 3; // no-warning
   }
 }
+
+// <rdar://problem/7185607>
+// Bit-fields of a struct should be invalidated when blasting the entire
+// struct with an integer constant.
+struct test_7185607 {
+  int x : 10;
+  int y : 22;
+};
+int rdar_test_7185607() {
+  struct test_7185607 s; // Uninitialized.
+  *((unsigned *) &s) = 0U;
+  return s.x; // no-warning
+}
+
+





More information about the cfe-commits mailing list