Skip to content

Renamed _noEagerMove attribute. #61048

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

Merged
merged 1 commit into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/ReferenceGuides/UnderscoredAttributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ that releases of the value may be hoisted without respect to deinit barriers.

When applied to a type, indicates that all values which are _statically_
instances of that type are themselves `@_eagerMove` as above, unless overridden
with `@_lexical`.
with `@_noEagerMove`.

Aggregates all of whose fields are `@_eagerMove` or trivial are inferred to be
`@_eagerMove`.
Expand Down Expand Up @@ -534,7 +534,7 @@ initializers from its superclass. This implies that all designated initializers
overridden. This attribute is often printed alongside
`@_hasMissingDesignatedInitializers` in this case.

## `@_lexical`
## `@_noEagerMove`

When applied to a value, indicates that the value's lifetime is lexical, that
releases of the value may not be hoisted over deinit barriers.
Expand All @@ -544,7 +544,7 @@ This is the default behavior, unless the value's type is annotated
annotation.

When applied to a type, indicates that all values which are instances of that
type are themselves `@_lexical` as above.
type are themselves `@_noEagerMove` as above.

This is the default behavior, unless the type annotated is an aggregate that
consists entirely of `@_eagerMove` or trivial values, in which case the
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
APIBreakingToAdd | APIBreakingToRemove,
118)

SIMPLE_DECL_ATTR(_lexical, Lexical,
SIMPLE_DECL_ATTR(_noEagerMove, NoEagerMove,
UserInaccessible |
ABIStableToAdd | ABIStableToRemove |
APIStableToAdd | APIStableToRemove |
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
auto &attrs = getAttrs();
if (attrs.hasAttribute<EagerMoveAttr>())
return LifetimeAnnotation::EagerMove;
if (attrs.hasAttribute<LexicalAttr>())
if (attrs.hasAttribute<NoEagerMoveAttr>())
return LifetimeAnnotation::Lexical;
return LifetimeAnnotation::None;
}
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsParse.def
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ ERROR(silfunc_and_silarg_have_incompatible_sil_value_ownership,none,
"Function type specifies: '@%0'. SIL argument specifies: '@%1'.",
(StringRef, StringRef))
ERROR(sil_arg_both_lexical_and_eagerMove,none,
"Function argument is annotated both @_eagerMove and @_lexical, "
"Function argument is annotated both @_eagerMove and @_noEagerMove, "
"but these are incompatible alternatives", ())
ERROR(expected_sil_colon,none,
"expected ':' before %0", (StringRef))
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -3240,7 +3240,7 @@ ERROR(inherits_executor_without_async,none,
ERROR(lifetime_invalid_global_scope,none, "%0 is only valid on methods",
(DeclAttribute))
ERROR(eagermove_and_lexical_combined,none,
"@_eagerMove and @_lexical attributes are alternate styles of lifetimes "
"@_eagerMove and @_noEagerMove attributes are alternate styles of lifetimes "
"and can't be combined", ())

ERROR(autoclosure_function_type,none,
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/LifetimeAnnotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace swift {
///
/// 1) None: No annotation has been applied.
/// 2) EagerMove: The @_eagerMove attribute has been applied.
/// 3) Lexical: The @_lexical attribute has been applied.
/// 3) NoEagerMove: The @_noEagerMove attribute has been applied.
struct LifetimeAnnotation {
enum Case : uint8_t {
None,
Expand Down
2 changes: 1 addition & 1 deletion lib/SILGen/SILGenProlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ struct ArgumentInitHelper {
// Look for the following annotations on the function argument:
// - @noImplicitCopy
// - @_eagerMove
// - @_lexical
// - @_noEagerMove
auto isNoImplicitCopy = pd->isNoImplicitCopy();
auto lifetime = SGF.F.getLifetime(pd, value->getType());

Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {

bool visitLifetimeAttr(DeclAttribute *attr);
void visitEagerMoveAttr(EagerMoveAttr *attr);
void visitLexicalAttr(LexicalAttr *attr);
void visitNoEagerMoveAttr(NoEagerMoveAttr *attr);

void visitCompilerInitializedAttr(CompilerInitializedAttr *attr);

Expand Down Expand Up @@ -6519,10 +6519,10 @@ void AttributeChecker::visitEagerMoveAttr(EagerMoveAttr *attr) {
return;
}

void AttributeChecker::visitLexicalAttr(LexicalAttr *attr) {
void AttributeChecker::visitNoEagerMoveAttr(NoEagerMoveAttr *attr) {
if (visitLifetimeAttr(attr))
return;
// @_lexical and @_eagerMove are opposites and can't be combined.
// @_noEagerMove and @_eagerMove are opposites and can't be combined.
if (D->getAttrs().hasAttribute<EagerMoveAttr>()) {
diagnoseAndRemoveAttr(attr, diag::eagermove_and_lexical_combined);
return;
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckDeclOverride.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ namespace {
UNINTERESTING_ATTR(AlwaysEmitConformanceMetadata)

UNINTERESTING_ATTR(EagerMove)
UNINTERESTING_ATTR(Lexical)
UNINTERESTING_ATTR(NoEagerMove)
#undef UNINTERESTING_ATTR

void visitAvailableAttr(AvailableAttr *attr) {
Expand Down
2 changes: 1 addition & 1 deletion test/SILGen/lexical_lifetime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ extension C {
// CHECK: {{bb[0-9]+}}({{%[^,]+}} : @_lexical @owned $C):
// CHECK-LABEL: } // end sil function 'lexical_method_attr'
@_silgen_name("lexical_method_attr")
@_lexical
@_noEagerMove
__consuming
func lexical_method_attr() {}

Expand Down
6 changes: 3 additions & 3 deletions test/SILOptimizer/inline_lifetime.sil
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct InferredEagerD2S1 {
var i4: InferredEagerD1S4
}

@_lexical
@_noEagerMove
struct LexicalS {
var i: InferredEagerD2S1
}
Expand All @@ -47,11 +47,11 @@ struct InferredLexicalD1S1 {
}

struct InferredLexicalD1S2 {
@_lexical var i: InferredEagerD2S1
@_noEagerMove var i: InferredEagerD2S1
}

struct InferredLexicalD1S3 {
@_lexical var i: InferredEagerD2S1
@_noEagerMove var i: InferredEagerD2S1
var j: InferredEagerD2S1
}

Expand Down
14 changes: 7 additions & 7 deletions test/attr/lexical.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ enum E {}
@_eagerMove // expected-error {{'@_eagerMove' attribute cannot be applied to this declaration}}
typealias EagerTuple = (C, C)

func foo(@_lexical @_eagerMove _ e: E) {} // expected-error {{@_eagerMove and @_lexical attributes are alternate styles of lifetimes and can't be combined}}
func foo(@_noEagerMove @_eagerMove _ e: E) {} // expected-error {{@_eagerMove and @_noEagerMove attributes are alternate styles of lifetimes and can't be combined}}

func bar(@_lexical _ s: S) {} // okay
func bar(@_noEagerMove _ s: S) {} // okay

func baz(@_eagerMove _ c: C) {} // okay

@_eagerMove // expected-error {{@_eagerMove is only valid on methods}}
func bazzoo(_ c: C) {}

@_lexical // expected-error {{@_lexical is only valid on methods}}
@_noEagerMove // expected-error {{@_noEagerMove is only valid on methods}}
func bazzoozoo(_ c: C) {}

extension C {
@_eagerMove
func pazzoo() {}

@_lexical
@_noEagerMove
func pazzoozoo() {}
}

struct S2 {
@_eagerMove let c: C // okay
@_lexical let e: E // okay
@_noEagerMove let e: E // okay
}

func foo() {
@_lexical let s1 = S()
@_noEagerMove let s1 = S()
@_eagerMove var s2 = S()
@_lexical @_eagerMove let s3 = S() // expected-error {{@_eagerMove and @_lexical attributes are alternate styles of lifetimes and can't be combined}}
@_noEagerMove @_eagerMove let s3 = S() // expected-error {{@_eagerMove and @_noEagerMove attributes are alternate styles of lifetimes and can't be combined}}
_ = s1
s2 = S()
_ = s2
Expand Down