forked from OSchip/llvm-project
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:
parent
a7a3a4c79e
commit
230e015b90
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue