diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-04-06 22:06:03 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-04-06 22:06:03 +0000 |
commit | f969841a1a04e4ca40311a2590f5be0a5d0a88f0 (patch) | |
tree | 2794fe90e2cc714fa12bb31a8965191483c5a4cb | |
parent | 5202269dc44b8f2423e1bb7673ab65e0d80b5698 (diff) | |
download | bcm5719-llvm-f969841a1a04e4ca40311a2590f5be0a5d0a88f0.tar.gz bcm5719-llvm-f969841a1a04e4ca40311a2590f5be0a5d0a88f0.zip |
Teach MemRegion::getBaseRegion() about ObjCIvarRegions. We want to treat
them the same way as fields. This fixes a regression in RegionStore::RemoveDeadbindings()
that emerged from going to the cluster-based analysis.
llvm-svn: 100570
-rw-r--r-- | clang/lib/Checker/MemRegion.cpp | 15 | ||||
-rw-r--r-- | clang/test/Analysis/misc-ps-region-store.m | 21 |
2 files changed, 29 insertions, 7 deletions
diff --git a/clang/lib/Checker/MemRegion.cpp b/clang/lib/Checker/MemRegion.cpp index 9f12ab622fb..0571d81f902 100644 --- a/clang/lib/Checker/MemRegion.cpp +++ b/clang/lib/Checker/MemRegion.cpp @@ -647,13 +647,14 @@ bool MemRegion::hasGlobalsOrParametersStorage() const { const MemRegion *MemRegion::getBaseRegion() const { const MemRegion *R = this; while (true) { - if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) { - R = ER->getSuperRegion(); - continue; - } - if (const FieldRegion *FR = dyn_cast<FieldRegion>(R)) { - R = FR->getSuperRegion(); - continue; + switch (R->getKind()) { + case MemRegion::ElementRegionKind: + case MemRegion::FieldRegionKind: + case MemRegion::ObjCIvarRegionKind: + R = cast<SubRegion>(R)->getSuperRegion(); + continue; + default: + break; } break; } diff --git a/clang/test/Analysis/misc-ps-region-store.m b/clang/test/Analysis/misc-ps-region-store.m index d10b9fa5ded..0e305bf1dfb 100644 --- a/clang/test/Analysis/misc-ps-region-store.m +++ b/clang/test/Analysis/misc-ps-region-store.m @@ -955,3 +955,24 @@ void pr6288_b(void) { *(px[0]) = 0; // no-warning } +// <rdar://problem/7817800> - A bug in RemoveDeadBindings was causing instance variable bindings +// to get prematurely pruned from the state. +@interface Rdar7817800 { + char *x; +} +- (void) rdar7817800_baz; +@end + +char *rdar7817800_foobar(); +void rdar7817800_qux(void*); + +@implementation Rdar7817800 +- (void) rdar7817800_baz { + if (x) + rdar7817800_qux(x); + x = rdar7817800_foobar(); + // Previously this triggered a bogus null dereference warning. + x[1] = 'a'; // no-warning +} +@end + |