mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
add an experimental feature DeferSendableChecking to defer the sendable checking of some sites. For now, only diagnostics corresponding to non-sendable arguments passed to calls with unsatisfied isolation are deferred. A SIL pass SendNonSendable is added to emit the deferred diagnostics, and ApplyExpr is appropriately enriched to make that deferral possible.
This commit is contained in:
34
lib/SILOptimizer/Mandatory/SendNonSendable.cpp
Normal file
34
lib/SILOptimizer/Mandatory/SendNonSendable.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "../../Sema/TypeCheckConcurrency.h"
|
||||
#include "swift/AST/Expr.h"
|
||||
#include "swift/SILOptimizer/PassManager/Transforms.h"
|
||||
|
||||
using namespace swift;
|
||||
|
||||
class SendNonSendable : public SILFunctionTransform {
|
||||
|
||||
// find any ApplyExprs in this function, and check if any of them make an
|
||||
// unsatisfied isolation jump, emitting appropriate diagnostics if so
|
||||
void run() override {
|
||||
SILFunction *function = getFunction();
|
||||
|
||||
if (!function->getASTContext().LangOpts
|
||||
.hasFeature(Feature::DeferredSendableChecking))
|
||||
return;
|
||||
|
||||
DeclContext *declContext = function->getDeclContext();
|
||||
|
||||
for (SILBasicBlock &bb : *function) {
|
||||
for (SILInstruction &instr : bb) {
|
||||
if (ApplyExpr *apply = instr.getLoc().getAsASTNode<ApplyExpr>()) {
|
||||
diagnoseApplyArgSendability(apply, declContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/// This pass is known to depend on the following passes having run before it:
|
||||
/// none so far
|
||||
SILTransform *swift::createSendNonSendable() {
|
||||
return new SendNonSendable();
|
||||
}
|
||||
Reference in New Issue
Block a user