|
| 1 | +//===--- PartitionOpError.def ----------------------------*- C++ -*--------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | +/// |
| 13 | +/// This file contains macros for creating PartitionOpErrors for use with |
| 14 | +/// SendNonSendable. This just makes it easier to add these errors without |
| 15 | +/// needing to write so much boielr plate. |
| 16 | +/// |
| 17 | +//===----------------------------------------------------------------------===// |
| 18 | + |
| 19 | +#ifndef PARTITION_OP_ERROR |
| 20 | +#define PARTITION_OP_ERROR(Name) |
| 21 | +#endif |
| 22 | + |
| 23 | +/// An error created if we discover a value was locally used after it |
| 24 | +/// was already sent. |
| 25 | +/// |
| 26 | +/// The arguments in the type are: |
| 27 | +/// |
| 28 | +/// 1. The PartitionOp that required the element to be alive. |
| 29 | +/// |
| 30 | +/// 2. The element in the PartitionOp that was asked to be alive. |
| 31 | +/// |
| 32 | +/// 3. The operand of the instruction that originally transferred the |
| 33 | +/// region. Can be used to get the immediate value transferred or the |
| 34 | +/// transferring instruction. |
| 35 | +PARTITION_OP_ERROR(LocalUseAfterSend) |
| 36 | + |
| 37 | +/// This is called if we detect a never sendable element that was actually sent. |
| 38 | +/// |
| 39 | +/// E.x.: passing a main actor exposed value to a sending parameter. |
| 40 | +PARTITION_OP_ERROR(SentNeverSendable) |
| 41 | + |
| 42 | +/// This is emitted when a never sendable value is passed into a sending |
| 43 | +/// result. The sending result will be viewed in our caller as disconnected and |
| 44 | +/// able to be sent. |
| 45 | +PARTITION_OP_ERROR(AssignNeverSendableIntoSendingResult) |
| 46 | + |
| 47 | +/// This is emitted when an inout sending parameter has been sent in a function |
| 48 | +/// body but has not been reinitialized at the end of the function. |
| 49 | +PARTITION_OP_ERROR(InOutSendingNotInitializedAtExit) |
| 50 | + |
| 51 | +/// This is emitted when an inout sending parameter has been assigned a |
| 52 | +/// non-disconnected value (e.x.: a value exposed to main actor isolated code) |
| 53 | +/// at end of function without being reinitialized with something disconnected. |
| 54 | +PARTITION_OP_ERROR(InOutSendingNotDisconnectedAtExit) |
| 55 | + |
| 56 | +/// Used to signify an "unknown code pattern" has occured while performing |
| 57 | +/// dataflow. |
| 58 | +/// |
| 59 | +/// DISCUSSION: Our dataflow cannot emit errors itself so this is a callback |
| 60 | +/// to our user so that we can emit that error as we process. |
| 61 | +PARTITION_OP_ERROR(UnknownCodePattern) |
| 62 | + |
| 63 | +#undef PARTITION_OP_ERROR |
0 commit comments