From: Ted Kremenek Date: Mon, 21 Sep 2009 22:58:52 +0000 (+0000) Subject: Provide intermediate solution to handling assignments to structs via an X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69181a863c9a87ea84e96157191f855043b86cfb;p=clang Provide intermediate solution to handling assignments to structs via an integer pointer. For now just invalidate the fields of the struct. This addresses: [RegionStore] support invalidation of bit fields using integer assignment git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82492 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 4186690939..f4f2fecc21 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -1302,6 +1302,10 @@ const GRState *RegionStoreManager::Bind(const GRState *state, Loc L, SVal V) { 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); } } } diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index 9f639ea610..c5bc0a68ff 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -167,3 +167,18 @@ void f() { *q = 3; // no-warning } } + +// +// 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 +} + +