summaryrefslogtreecommitdiff
path: root/test/Analysis/retain-release.mm
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-05-02 21:21:42 +0000
committerTed Kremenek <kremenek@apple.com>2011-05-02 21:21:42 +0000
commit9ca2851de4cc62ddd8466312603fe41bdac10eb5 (patch)
treed93413330ec2cb7f67376119656c953ea3fa15c4 /test/Analysis/retain-release.mm
parent1a584022c86bd0778cf7ad1fbea08c78869cf216 (diff)
downloadclang-9ca2851de4cc62ddd8466312603fe41bdac10eb5.tar.gz
Tweak the retain/release checker to not stop tracking retained objects when calling C++ methods. This is a temporary solution to prune false positives until we have a general story using annotations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130726 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/retain-release.mm')
-rw-r--r--test/Analysis/retain-release.mm22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm
index 47d615f188..0faeb1a2a3 100644
--- a/test/Analysis/retain-release.mm
+++ b/test/Analysis/retain-release.mm
@@ -275,10 +275,32 @@ class SmartPointer {
public:
SmartPointer(id x) : x(x) {}
~SmartPointer() { [x release]; }
+
+ void adopt(id x);
+ void noAdopt(id x);
};
+void test_positive() {
+ id x = [[NSObject alloc] init]; // expected-warning {{leak}}
+}
+
void test_smartpointer_1() {
id x = [[NSObject alloc] init]; // no-warning
SmartPointer foo(x);
}
+void test_smartpointer_2() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(0);
+ foo.adopt(x);
+}
+
+// FIXME: Eventually we want annotations to say whether or not
+// a C++ method claims ownership of an Objective-C object.
+void test_smartpointer_3() {
+ id x = [[NSObject alloc] init]; // no-warning
+ SmartPointer foo(0);
+ foo.noAdopt(x);
+}
+
+