diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-12-09 08:32:57 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-12-09 08:32:57 +0000 |
commit | 2f4a6b25a7409f6f05e8a5e6864de21a337c8958 (patch) | |
tree | 28c46809e4067feed42c892350032b98cb2f2a4d | |
parent | eac813909b3ca1142ad186f6c6a1b1ae0dbf9378 (diff) |
OSAtomic simulation: use the original region as the location to load from,
instead of the ElementRegion obtained from casts.
Test cast: the leak cannot occur bacause the true branch cannot be taken.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90964 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 7 | ||||
-rw-r--r-- | lib/Analysis/Store.cpp | 4 | ||||
-rw-r--r-- | test/Analysis/NSString.m | 4 |
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 4a960c6937..daa249f901 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1483,10 +1483,13 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst, ExplodedNodeSet Tmp; SVal location = state->getSVal(theValueExpr); // Here we should use the value type of the region as the load type. - const MemRegion *R = location.getAsRegion(); + const MemRegion *R = location.getAsRegion()->StripCasts(); QualType LoadTy; - if (R) + if (R) { LoadTy = cast<TypedRegion>(R)->getValueType(C); + // Use the region as the real load location. + location = loc::MemRegionVal(R); + } Engine.EvalLoad(Tmp, theValueExpr, Pred, state, location, OSAtomicLoadTag, LoadTy); diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp index e591842838..be4ce2d57c 100644 --- a/lib/Analysis/Store.cpp +++ b/lib/Analysis/Store.cpp @@ -199,7 +199,7 @@ SVal StoreManager::CastRetrievedVal(SVal V, const TypedRegion *R, QualType castTy) { if (castTy.isNull()) return V; - + assert(ValMgr.getContext().hasSameUnqualifiedType(castTy, R->getValueType(ValMgr.getContext()))); return V; @@ -228,4 +228,4 @@ const GRState *StoreManager::InvalidateRegions(const GRState *state, SVal StoreManager::getLValueCompoundLiteral(const CompoundLiteralExpr* CL, const LocationContext *LC) { return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC)); -}
\ No newline at end of file +} diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m index 481a94055f..295cac4275 100644 --- a/test/Analysis/NSString.m +++ b/test/Analysis/NSString.m @@ -302,7 +302,7 @@ void testOSCompareAndSwapXXBarrier() { void testOSCompareAndSwapXXBarrier_positive() { NSString *old = 0; - NSString *s = [[NSString alloc] init]; // expected-warning{{leak}} + NSString *s = [[NSString alloc] init]; // no-warning if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old)) return; else @@ -326,7 +326,7 @@ void test_objc_atomicCompareAndSwap() { void test_objc_atomicCompareAndSwap_positive() { NSString *old = 0; - NSString *s = [[NSString alloc] init]; // expected-warning{{leak}} + NSString *s = [[NSString alloc] init]; // no-warning if (!objc_atomicCompareAndSwapPtr(0, s, &old)) return; else |