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
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);
QualType castTy) {
if (castTy.isNull())
return V;
-
+
assert(ValMgr.getContext().hasSameUnqualifiedType(castTy,
R->getValueType(ValMgr.getContext())));
return V;
SVal StoreManager::getLValueCompoundLiteral(const CompoundLiteralExpr* CL,
const LocationContext *LC) {
return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC));
-}
\ No newline at end of file
+}
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
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