Skip to content

Commit e518a86

Browse files
committed
[move-function] Implement SILFunction::isDefer().
Returns true if this SILFunction must be a defer. NOTE: This may return false for defer statements that have been deserialized without a DeclContext. This means that this is guaranteed to be correct for SILFunctions in Raw SIL that were not deserialized as canonical. Thus one can use it for diagnostics. (cherry picked from commit fe6e3f9)
1 parent 86cdaa8 commit e518a86

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,19 @@ class SILFunction
10291029
/// generic.
10301030
SubstitutionMap getForwardingSubstitutionMap();
10311031

1032+
/// Returns true if this SILFunction must be a defer statement.
1033+
///
1034+
/// NOTE: This may return false for defer statements that have been
1035+
/// deserialized without a DeclContext. This means that this is guaranteed to
1036+
/// be correct for SILFunctions in Raw SIL that were not deserialized as
1037+
/// canonical. Thus one can use it for diagnostics.
1038+
bool isDefer() const {
1039+
if (auto *dc = getDeclContext())
1040+
if (auto *decl = dyn_cast_or_null<FuncDecl>(dc->getAsDecl()))
1041+
return decl->isDeferBody();
1042+
return false;
1043+
}
1044+
10321045
//===--------------------------------------------------------------------===//
10331046
// Block List Access
10341047
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)