diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 4 | ||||
-rw-r--r-- | clang/test/Analysis/misc-ps-region-store.m | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 41866909391..f4f2fecc214 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/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/clang/test/Analysis/misc-ps-region-store.m b/clang/test/Analysis/misc-ps-region-store.m index 9f639ea6101..c5bc0a68ffc 100644 --- a/clang/test/Analysis/misc-ps-region-store.m +++ b/clang/test/Analysis/misc-ps-region-store.m @@ -167,3 +167,18 @@ void f() { *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 +} + + |