S = getPersistentStopSummary();
break;
}
+ // For C++ methods, generate an implicit "stop" summary as well. We
+ // can relax this once we have a clear policy for C++ methods and
+ // ownership attributes.
+ if (isa<CXXMethodDecl>(FD)) {
+ S = getPersistentStopSummary();
+ break;
+ }
// [PR 3337] Use 'getAs<FunctionType>' to strip away any typedefs on the
// function's type.
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);
+}
+
+