Skip to content

Commit f23ad55

Browse files
committed
[region-isolation] Eliminate CRTP for errors and just pass through an error struct instead.
This is going to let me just pass through the error struct to the diagnostic rather than having the CRTP and then constructing an info object per CRTP. Currently, to make it easier to refactor, I changed the code in TransferNonSendable to just take in the new error and call the current CRTP routines. In the next commit, I am going to refactor TransferNonSendable.cpp itself. This just makes it easier to test that I did not break anything.
1 parent 4db04f9 commit f23ad55

File tree

4 files changed

+321
-154
lines changed

4 files changed

+321
-154
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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

Comments
 (0)