Page MenuHomePhabricator

canonicalize macOS 10.16 availability to macOS 11 while preserving uses of if @available macOS 10.16
AcceptedPublic

Authored by arphaman on Jun 29 2020, 5:11 PM.

Details

Summary

This patch canonicalizes the macOS versions in the availability, so that clang can treat macOS 10.16 availability as macOS 11 availability. The if (@available (macOS 10.16, *) checks still preserve their original version in the generated code to ensure that the software running on macOS Big Sur Beta 1 can still exhibits the expected runtime behavior for the 10.16 availability checks.

Diff Detail

Event Timeline

arphaman created this revision.Jun 29 2020, 5:11 PM
aaron.ballman added inline comments.Jun 30 2020, 5:34 AM
clang/include/clang/AST/ExprObjC.h
1719–1721

Any reason these functions aren't marked const?

erik.pilkington accepted this revision.Jun 30 2020, 9:15 AM

LGTM, after mine and Aaron's comments.

clang/lib/Sema/SemaExpr.cpp
19195–19211

nit: The lambda returning an optional seems a little overkill here, e.g. seems this could just be:

ObjCAvailabilityCheckExpr::VersionAsWritten Version;
if (Spec != AvailSpecs.end()) {
  if (Platform == "macos") {
    Version = ObjCAvailabilityCheckExpr::VersionAsWritten{
        llvm::Triple::getCanonicalVersionForOS(llvm::Triple::MacOSX,
                                               Spec->getVersion()),
        Spec->getVersion()};
  } else {
    Version = ObjCAvailabilityCheckExpr::VersionAsWritten{Spec->getVersion(),
                                                   Spec->getVersion()};
  }
}
This revision is now accepted and ready to land.Jun 30 2020, 9:15 AM