-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[TypeChecker/SILGen] Dynamic enforcement of witness/objc isolation with @preconcurrency attribute #70867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TypeChecker/SILGen] Dynamic enforcement of witness/objc isolation with @preconcurrency attribute #70867
Changes from all commits
574aee0
233d279
4943e14
e8b7a26
a26af37
4513084
65b07e9
0e6dbd5
13f8359
1caafee
c3a0822
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -444,11 +444,11 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
|
||
// Flag bits used in ContextAndBits. | ||
enum { | ||
/// The conformance is invalid. | ||
InvalidFlag = 0x01, | ||
|
||
/// The conformance was labeled with @unchecked. | ||
UncheckedFlag = 0x02, | ||
UncheckedFlag = 0x01, | ||
|
||
/// The conformance was labeled with @preconcurrency. | ||
PreconcurrencyFlag = 0x02, | ||
|
||
/// We have allocated the AssociatedConformances array (but not necessarily | ||
/// populated any of its elements). | ||
|
@@ -458,10 +458,13 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
/// The declaration context containing the ExtensionDecl or | ||
/// NominalTypeDecl that declared the conformance. | ||
/// | ||
/// Also stores the "invalid", "unchecked" and "has computed associated | ||
/// Also stores the "unchecked", "preconcurrency" and "has computed associated | ||
/// conformances" bits. | ||
llvm::PointerIntPair<DeclContext *, 3, unsigned> ContextAndBits; | ||
|
||
/// Indicates whether the conformance is invalid. | ||
bool Invalid : 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can combine the bits from ContextAndBits and SourceKindAndImplyingConformance with 'Invalid' into a single bitfield There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We discussed this offline with Slava and I'm going to follow-up with bitfield changes in a separate PR. |
||
|
||
/// The reason that this conformance exists. | ||
/// | ||
/// Either Explicit (e.g. 'struct Foo: Protocol {}' or 'extension Foo: | ||
|
@@ -501,12 +504,14 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
public: | ||
NormalProtocolConformance(Type conformingType, ProtocolDecl *protocol, | ||
SourceLoc loc, DeclContext *dc, | ||
ProtocolConformanceState state, | ||
bool isUnchecked) | ||
ProtocolConformanceState state, bool isUnchecked, | ||
bool isPreconcurrency) | ||
: RootProtocolConformance(ProtocolConformanceKind::Normal, | ||
conformingType), | ||
ProtocolAndState(protocol, state), Loc(loc), | ||
ContextAndBits(dc, isUnchecked ? UncheckedFlag : 0) { | ||
ContextAndBits(dc, ((isUnchecked ? UncheckedFlag : 0) | | ||
(isPreconcurrency ? PreconcurrencyFlag : 0))), | ||
Invalid(false) { | ||
assert(!conformingType->hasArchetype() && | ||
"ProtocolConformances should store interface types"); | ||
} | ||
|
@@ -543,12 +548,12 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
|
||
/// Determine whether this conformance is invalid. | ||
bool isInvalid() const { | ||
return ContextAndBits.getInt() & InvalidFlag; | ||
return Invalid; | ||
} | ||
|
||
/// Mark this conformance as invalid. | ||
void setInvalid() { | ||
ContextAndBits.setInt(ContextAndBits.getInt() | InvalidFlag); | ||
Invalid = true; | ||
} | ||
|
||
/// Whether this is an "unchecked" conformance. | ||
|
@@ -563,6 +568,9 @@ class NormalProtocolConformance : public RootProtocolConformance, | |
ContextAndBits.setInt(ContextAndBits.getInt() | UncheckedFlag); | ||
} | ||
|
||
/// Whether this is an preconcurrency conformance. | ||
bool isPreconcurrency() const; | ||
|
||
/// Determine whether we've lazily computed the associated conformance array | ||
/// already. | ||
bool hasComputedAssociatedConformances() const { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be bitfields?