[cfe-commits] r100570 - in /cfe/trunk: lib/Checker/MemRegion.cpp test/Analysis/misc-ps-region-store.m
Ted Kremenek
kremenek at apple.com
Tue Apr 6 15:06:04 PDT 2010
Author: kremenek
Date: Tue Apr 6 17:06:03 2010
New Revision: 100570
URL: http://llvm.org/viewvc/llvm-project?rev=100570&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Checker/MemRegion.cpp
cfe/trunk/test/Analysis/misc-ps-region-store.m
Modified: cfe/trunk/lib/Checker/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MemRegion.cpp?rev=100570&r1=100569&r2=100570&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MemRegion.cpp (original)
+++ cfe/trunk/lib/Checker/MemRegion.cpp Tue Apr 6 17:06:03 2010
@@ -647,13 +647,14 @@
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;
}
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=100570&r1=100569&r2=100570&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.m Tue Apr 6 17:06:03 2010
@@ -955,3 +955,24 @@
*(px[0]) = 0; // no-warning
}
+// <rdar://problem/7817800> - A bug in RemoveDeadBindings was causing instance variable bindings
+// to get prematurely pruned from the state.
+ at interface Rdar7817800 {
+ char *x;
+}
+- (void) rdar7817800_baz;
+ at end
+
+char *rdar7817800_foobar();
+void rdar7817800_qux(void*);
+
+ at 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
+}
+ at end
+
More information about the cfe-commits
mailing list