Add resilience boundary around non-inlinable bodies

Previously, the availability checker has assumed that no code in a module is available on less than the minimum deployment target. In modules using library evolution, this is not actually true--certain function bodies can be inlined into modules with lower minimum deployment targets, where they can run against versions of the library that had lower minimum deployment targets. By failing to check for availability violations in these function bodies that relate to versions below the minimum deployment target, we can end up allowing inlinable code that doesn't compile with the correct runtime linkage or has other serious problems.

This commit lowers the root type refinement context's avialability to the value of the -target-min-inlining-version option (if provided) and then raises it again inside the bodies of functions whose implementations are not exposed to clients. This introduces some incorrect typechecking of declaration signatures, but we'll fix that in another commit.
This commit is contained in:
Becca Royal-Gordon
2021-08-20 22:58:10 -07:00
committed by Allan Shortlidge
parent c80a19e19e
commit c67804902f
6 changed files with 600 additions and 11 deletions

View File

@@ -217,6 +217,10 @@ public:
/// deployment target.
static AvailabilityContext forDeploymentTarget(ASTContext &Ctx);
/// Creates a context that imposes the constraints of the ASTContext's
/// inlining target (i.e. minimum inlining version).
static AvailabilityContext forInliningTarget(ASTContext &Ctx);
/// Creates a context that imposes no constraints.
///
/// \see isAlwaysAvailable