[go: nahoru, domu]

Ban the inclusion of <objc/objc.h>

It's dangerous in mixed ARC/non-ARC code.

Fixed: 1429730
Change-Id: I6f65fdeb8077f43a53076db36528f2bf0e4ca82e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4406661
Commit-Queue: Avi Drissman <avi@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1129944}
diff --git a/testing/platform_test_mac.mm b/testing/platform_test_mac.mm
index 30126fc..d52ad37 100644
--- a/testing/platform_test_mac.mm
+++ b/testing/platform_test_mac.mm
@@ -4,12 +4,17 @@
 
 #include "platform_test.h"
 
-#import <Foundation/Foundation.h>
+// Note that this uses the direct runtime interface to the autorelease pool.
+// https://clang.llvm.org/docs/AutomaticReferenceCounting.html#runtime-support
+// This is so this can work when compiled for ARC.
 
-PlatformTest::PlatformTest()
-    : pool_([[NSAutoreleasePool alloc] init]) {
+extern "C" {
+void* objc_autoreleasePoolPush(void);
+void objc_autoreleasePoolPop(void* pool);
 }
 
+PlatformTest::PlatformTest() : autorelease_pool_(objc_autoreleasePoolPush()) {}
+
 PlatformTest::~PlatformTest() {
-  [pool_ release];
+  objc_autoreleasePoolPop(autorelease_pool_);
 }