summaryrefslogtreecommitdiff
path: root/test/Analysis/retain-release.mm
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-03-20 00:10:35 +0000
committerTed Kremenek <kremenek@apple.com>2012-03-20 00:10:35 +0000
commitd967c6a17576b83cdeba656ce10f9676ceb009c0 (patch)
treeddd9bf343e359d340bdf1290288de777d1731368 /test/Analysis/retain-release.mm
parent4cf225382a8b061dce41733c962d62b6db9721f8 (diff)
downloadclang-d967c6a17576b83cdeba656ce10f9676ceb009c0.tar.gz
Add test case for <rdar://problem/10553686>, which illustrates RetainCount checker working with inlined C++ template functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153069 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/retain-release.mm')
-rw-r--r--test/Analysis/retain-release.mm26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm
index 8c707acfc3..0b550a8e0f 100644
--- a/test/Analysis/retain-release.mm
+++ b/test/Analysis/retain-release.mm
@@ -321,3 +321,29 @@ void test_Scopy() {
NSString *token = (NSString*) Scopy();
[token release]; // expected-warning {{object that is not owned}}
}
+
+//===----------------------------------------------------------------------===//
+// Test handling of template functions used to do magic with
+// tracked retained pointers.
+//===----------------------------------------------------------------------===//
+
+template <typename T, typename U> T static_objc_cast(U* value)
+{
+ // ...debugging code omitted...
+ return static_cast<T>(value);
+}
+
+int rdar10553686(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]);
+ [bar release];
+ return 0;
+}
+int rdar10553686_positive(void)
+{
+ NSObject* bar = static_objc_cast<NSObject*>([[NSObject alloc] init]); // expected-warning {{Potential leak}}
+ [bar release];
+ [bar retain];
+ return 0;
+}
+