Enhance SVals::getAsRegion: get the region that is converted to an integer.
This with previous patch fixes a OSAtomic test case.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93146 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp
index 9163b27..fbdb73b 100644
--- a/lib/Analysis/SVals.cpp
+++ b/lib/Analysis/SVals.cpp
@@ -97,6 +97,10 @@
if (const loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(this))
return X->getRegion();
+ if (const nonloc::LocAsInteger *X = dyn_cast<nonloc::LocAsInteger>(this)) {
+ return X->getLoc().getAsRegion();
+ }
+
return 0;
}
diff --git a/test/Analysis/NSString-failed-cases.m b/test/Analysis/NSString-failed-cases.m
index 2b8242f..699d142 100644
--- a/test/Analysis/NSString-failed-cases.m
+++ b/test/Analysis/NSString-failed-cases.m
@@ -97,15 +97,6 @@
//===----------------------------------------------------------------------===//
// FIXME: THIS TEST CASE INCORRECTLY REPORTS A LEAK.
-void testOSCompareAndSwapXXBarrier_parameter(NSString **old) {
- NSString *s = [[NSString alloc] init]; // no-warning
- if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) old))
- [s release];
- else
- [*old release];
-}
-
-// FIXME: THIS TEST CASE INCORRECTLY REPORTS A LEAK.
void testOSCompareAndSwapXXBarrier_parameter_no_direct_release(NSString **old) {
NSString *s = [[NSString alloc] init]; // no-warning
if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) old))
diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m
index fb44309..b5d510a 100644
--- a/test/Analysis/NSString.m
+++ b/test/Analysis/NSString.m
@@ -388,3 +388,11 @@
}
}
@end
+
+void testOSCompareAndSwapXXBarrier_parameter(NSString **old) {
+ NSString *s = [[NSString alloc] init]; // no-warning
+ if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) old))
+ [s release];
+ else
+ [*old release];
+}