summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/retain-release-inline.m
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-03-23 06:26:56 +0000
committerTed Kremenek <kremenek@apple.com>2012-03-23 06:26:56 +0000
commit161046edabfaaec73b320da65b4dc48da07973cd (patch)
treeb3e6ce534252c77cdec0b25446b7d8186f3f4b58 /clang/test/Analysis/retain-release-inline.m
parentaefeaa9873bb8a0f997498e7b28d0d6d9742f9aa (diff)
downloadbcm5719-llvm-161046edabfaaec73b320da65b4dc48da07973cd.tar.gz
bcm5719-llvm-161046edabfaaec73b320da65b4dc48da07973cd.zip
Avoid applying retain/release effects twice in RetainCountChecker when a function call was inlined (i.e., we do not need to apply summaries in such cases).
llvm-svn: 153309
Diffstat (limited to 'clang/test/Analysis/retain-release-inline.m')
-rw-r--r--clang/test/Analysis/retain-release-inline.m31
1 files changed, 31 insertions, 0 deletions
diff --git a/clang/test/Analysis/retain-release-inline.m b/clang/test/Analysis/retain-release-inline.m
index cbef9995bc6..610df7f7e94 100644
--- a/clang/test/Analysis/retain-release-inline.m
+++ b/clang/test/Analysis/retain-release-inline.m
@@ -314,3 +314,34 @@ void test_test_return_retained() {
[x retain];
[x release];
}
+
+//===----------------------------------------------------------------------===//
+// Test not applying "double effects" from inlining and RetainCountChecker summaries.
+// If we inline a call, we should already see its retain/release semantics.
+//===----------------------------------------------------------------------===//
+
+__attribute__((cf_returns_retained)) CFStringRef test_return_inline(CFStringRef x) {
+ CFRetain(x);
+ return x;
+}
+
+void test_test_return_inline(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0);
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+ // After this call, 'str2' and 'str' has a +0 reference count.
+ CFRelease(str2);
+}
+
+void test_test_return_inline_2(char *bytes) {
+ CFStringRef str = CFStringCreateWithCStringNoCopy(0, bytes, NSNEXTSTEPStringEncoding, 0); // expected-warning {{leak}}
+ // After this call, 'str' really has +2 reference count.
+ CFStringRef str2 = test_return_inline(str);
+ // After this call, 'str' really has a +1 reference count.
+ CFRelease(str);
+}
+
+
+
OpenPOWER on IntegriCloud