[PATCH] D27827: [ObjC] CodeGen support for @available on macOS
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 15 13:25:27 PST 2016
erik.pilkington created this revision.
erik.pilkington added reviewers: manmanren, dexonsmith, rjmccall, thakis.
erik.pilkington added a subscriber: cfe-commits.
This patch adds CodeGen support for `@available` on macos. This is done by compiling @available predicates into calls to `clang.is_os_version_at_least`. This function first populates 3 global variables which hold the major, minor and subminor with the operating system version, using core services' `Gestalt()` (https://developer.apple.com/reference/coreservices/1471624-gestalt?language=objc), and grand central dispatch's `dispatch_once_f` to make sure that this is only done once. After that, it compares the version that was passed to it with the host's OS version.
Unfortunately, `Gestalt()` is only available on macOS. In a follow-up patch, we can add support for other platforms. I think that the best way of doing that is to depend on Objective-C's `NSProcessInfo`. I'm not super familiar with this part of the compiler, and in particular I'm unsure of whether we should be directly calling into library functions like `Gestalt` and `dispatch_once_f`, so please tear this patch apart!
This patch is part of a feature that I proposed last summer here:
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 15507 bytes
Desc: not available
More information about the cfe-commits