Skip to content

Commit 2df8a76

Browse files
committed
FIXUP
1 parent 2a3c533 commit 2df8a76

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

include/swift/AST/Decl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,8 +1094,20 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
10941094
/// Check if this is a declaration defined at the top level of the Swift module
10951095
bool isStdlibDecl() const;
10961096

1097+
/// The effective lifetime resulting from the decorations on the declaration.
1098+
///
1099+
/// Usually, this, not getLifetimeAnnotationFromAttributes should be used.
10971100
LifetimeAnnotation getLifetimeAnnotation() const;
10981101

1102+
/// The source-level lifetime attribute, either @_eagerMove or @_noEagerMove
1103+
/// that the declaration bears.
1104+
///
1105+
/// Usually getLifetimeAnnotation should be used.
1106+
///
1107+
/// Needed to access the attributes before the AST has been fully formed, such
1108+
/// as when printing.
1109+
LifetimeAnnotation getLifetimeAnnotationFromAttributes() const;
1110+
10991111
bool isNoImplicitCopy() const {
11001112
return getAttrs().hasAttribute<NoImplicitCopyAttr>();
11011113
}

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ namespace {
10301030
if (P->getAttrs().hasAttribute<NonEphemeralAttr>())
10311031
OS << " nonEphemeral";
10321032

1033-
switch (P->getLifetimeAnnotation()) {
1033+
switch (P->getLifetimeAnnotationFromAttributes()) {
10341034
case LifetimeAnnotation::EagerMove:
10351035
OS << " _eagerMove";
10361036
break;

lib/AST/Decl.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,8 @@ bool Decl::isStdlibDecl() const {
10801080
DC->getParentModule()->isStdlibModule();
10811081
}
10821082

1083-
static LifetimeAnnotation
1084-
getLifetimeAnnotationFromAttributes(const Decl *decl) {
1085-
auto &attrs = decl->getAttrs();
1083+
LifetimeAnnotation Decl::getLifetimeAnnotationFromAttributes() const {
1084+
auto &attrs = getAttrs();
10861085
if (attrs.hasAttribute<EagerMoveAttr>())
10871086
return LifetimeAnnotation::EagerMove;
10881087
if (attrs.hasAttribute<NoEagerMoveAttr>())
@@ -1097,7 +1096,7 @@ LifetimeAnnotation Decl::getLifetimeAnnotation() const {
10971096
if (auto *fd = dyn_cast<FuncDecl>(this)) {
10981097
return fd->getLifetimeAnnotation();
10991098
}
1100-
return getLifetimeAnnotationFromAttributes(this);
1099+
return getLifetimeAnnotationFromAttributes();
11011100
}
11021101

11031102
AvailabilityContext Decl::getAvailabilityForLinkage() const {
@@ -7052,7 +7051,7 @@ LifetimeAnnotation ParamDecl::getLifetimeAnnotation() const {
70527051
if (specifier == ParamDecl::Specifier::Consuming &&
70537052
!getType()->isPureMoveOnly())
70547053
return LifetimeAnnotation::EagerMove;
7055-
return getLifetimeAnnotationFromAttributes(this);
7054+
return getLifetimeAnnotationFromAttributes();
70567055
}
70577056

70587057
StringRef ParamDecl::getSpecifierSpelling(ParamSpecifier specifier) {
@@ -9247,7 +9246,7 @@ LifetimeAnnotation FuncDecl::getLifetimeAnnotation() const {
92479246
if (selfDecl && !selfDecl->getType()->isPureMoveOnly())
92489247
return LifetimeAnnotation::EagerMove;
92499248
}
9250-
return getLifetimeAnnotationFromAttributes(this);
9249+
return getLifetimeAnnotationFromAttributes();
92519250
}
92529251

92539252
bool FuncDecl::isCallAsFunctionMethod() const {

test/SILOptimizer/consuming_parameter.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
// RUN: %target-swift-frontend -c -Xllvm --sil-print-final-ossa-module -O -module-name=main -o /dev/null %s 2>&1 | %FileCheck %s
1+
// RUN: %target-swift-frontend -c -disable-availability-checking -Xllvm --sil-print-final-ossa-module -O -module-name=main -o /dev/null %s 2>&1 | %FileCheck %s
22

3+
// REQUIRES: concurrency
4+
35
// CHECK-LABEL: sil [ossa] @async_dead_arg_call : {{.*}} {
46
// CHECK: {{bb[0-9]+}}([[INSTANCE:%[^,]+]] : @_eagerMove @owned
57
// CHECK: destroy_value [[INSTANCE]]

0 commit comments

Comments
 (0)