Add test case for <rdar://problem/10553686>, which illustrates RetainCount checker working with inlined C++ template functions.

llvm-svn: 153069
This commit is contained in:
Ted Kremenek 2012-03-20 00:10:35 +00:00
parent a7a3a4c79e
commit 230e015b90
1 changed files with 26 additions and 0 deletions

View File

@ -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;
}