summaryrefslogtreecommitdiffstats
path: root/test/Analysis/retain-release.mm
diff options
context:
space:
mode:
authorJordan Rupprecht <rupprecht@google.com>2019-05-14 21:58:59 +0000
committerJordan Rupprecht <rupprecht@google.com>2019-05-14 21:58:59 +0000
commitb35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch)
treecdff4a5d1a715d4ad622fd8f190128b54bebe440 /test/Analysis/retain-release.mm
parent3748d41833787fcbf59cc5624e8d2b042a8991bc (diff)
parent741e05796da92b46d4f7bcbee00702ff37df6489 (diff)
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/retain-release.mm')
-rw-r--r--test/Analysis/retain-release.mm64
1 files changed, 63 insertions, 1 deletions
diff --git a/test/Analysis/retain-release.mm b/test/Analysis/retain-release.mm
index 5dc8f857d8..1c0c1999d7 100644
--- a/test/Analysis/retain-release.mm
+++ b/test/Analysis/retain-release.mm
@@ -471,7 +471,6 @@ void rdar33832412() {
void* x = IOBSDNameMatching(); // no-warning
}
-
namespace member_CFRetains {
class Foo {
public:
@@ -485,3 +484,66 @@ void bar() {
foo.CFRetain(0); // no-warning
}
}
+
+namespace cxx_method_escaping {
+
+struct S {
+ static CFArrayRef testGetNoTracking();
+ CFArrayRef testGetNoTrackingMember();
+};
+
+void test_cxx_static_method_escaping() {
+ CFArrayRef arr = S::testGetNoTracking();
+ CFRelease(arr);
+}
+
+void test_cxx_method_escaping(S *s) {
+ CFArrayRef arr = s->testGetNoTrackingMember();
+ CFRelease(arr);
+}
+
+}
+
+namespace yet_another_unexpected_signature_crash {
+
+CFTypeRef CFSomethingSomethingRetain();
+CFTypeRef CFSomethingSomethingAutorelease();
+
+void foo() {
+ CFSomethingSomethingRetain(); // no-crash
+ CFSomethingSomethingAutorelease(); // no-crash
+}
+
+}
+
+namespace reinterpret_casts {
+
+void *foo() {
+ void *p = const_cast<void *>(
+ reinterpret_cast<const void *>(CFArrayCreate(0, 0, 0, 0)));
+ void *q = reinterpret_cast<void *>(
+ reinterpret_cast<char *>(p) + 1);
+ // FIXME: Should warn about a leak here. The function should return at +0,
+ // but it returns at +1 instead.
+ return q;
+}
+
+void *fooCreate() {
+ void *p = const_cast<void *>(
+ reinterpret_cast<const void *>(CFArrayCreate(0, 0, 0, 0)));
+ void *q = reinterpret_cast<void *>(
+ reinterpret_cast<char *>(p) + 1);
+ // The function follows the Create Rule.
+ return q; // no-warning
+}
+
+void *fooBar() CF_RETURNS_RETAINED {
+ void *p = const_cast<void *>(
+ reinterpret_cast<const void *>(CFArrayCreate(0, 0, 0, 0)));
+ void *q = reinterpret_cast<void *>(
+ reinterpret_cast<char *>(p) + 1);
+ // The function follows the Create Rule.
+ return q; // no-warning
+}
+
+}