forked from OSchip/llvm-project
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. llvm-svn: 90964
This commit is contained in:
parent
f92d732c99
commit
1d153328be
|
@ -1483,10 +1483,13 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet& Dst,
|
||||||
ExplodedNodeSet Tmp;
|
ExplodedNodeSet Tmp;
|
||||||
SVal location = state->getSVal(theValueExpr);
|
SVal location = state->getSVal(theValueExpr);
|
||||||
// Here we should use the value type of the region as the load type.
|
// 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;
|
QualType LoadTy;
|
||||||
if (R)
|
if (R) {
|
||||||
LoadTy = cast<TypedRegion>(R)->getValueType(C);
|
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,
|
Engine.EvalLoad(Tmp, theValueExpr, Pred, state, location, OSAtomicLoadTag,
|
||||||
LoadTy);
|
LoadTy);
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,7 @@ SVal StoreManager::CastRetrievedVal(SVal V, const TypedRegion *R,
|
||||||
QualType castTy) {
|
QualType castTy) {
|
||||||
if (castTy.isNull())
|
if (castTy.isNull())
|
||||||
return V;
|
return V;
|
||||||
|
|
||||||
assert(ValMgr.getContext().hasSameUnqualifiedType(castTy,
|
assert(ValMgr.getContext().hasSameUnqualifiedType(castTy,
|
||||||
R->getValueType(ValMgr.getContext())));
|
R->getValueType(ValMgr.getContext())));
|
||||||
return V;
|
return V;
|
||||||
|
@ -228,4 +228,4 @@ const GRState *StoreManager::InvalidateRegions(const GRState *state,
|
||||||
SVal StoreManager::getLValueCompoundLiteral(const CompoundLiteralExpr* CL,
|
SVal StoreManager::getLValueCompoundLiteral(const CompoundLiteralExpr* CL,
|
||||||
const LocationContext *LC) {
|
const LocationContext *LC) {
|
||||||
return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC));
|
return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC));
|
||||||
}
|
}
|
||||||
|
|
|
@ -302,7 +302,7 @@ void testOSCompareAndSwapXXBarrier() {
|
||||||
|
|
||||||
void testOSCompareAndSwapXXBarrier_positive() {
|
void testOSCompareAndSwapXXBarrier_positive() {
|
||||||
NSString *old = 0;
|
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))
|
if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
|
@ -326,7 +326,7 @@ void test_objc_atomicCompareAndSwap() {
|
||||||
|
|
||||||
void test_objc_atomicCompareAndSwap_positive() {
|
void test_objc_atomicCompareAndSwap_positive() {
|
||||||
NSString *old = 0;
|
NSString *old = 0;
|
||||||
NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
|
NSString *s = [[NSString alloc] init]; // no-warning
|
||||||
if (!objc_atomicCompareAndSwapPtr(0, s, &old))
|
if (!objc_atomicCompareAndSwapPtr(0, s, &old))
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue