Skip to content

Commit fe6e3f9

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.
1 parent 5dc8b38 commit fe6e3f9

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
@@ -1056,6 +1056,19 @@ class SILFunction
10561056
/// generic.
10571057
SubstitutionMap getForwardingSubstitutionMap();
10581058

1059+
/// Returns true if this SILFunction must be a defer statement.
1060+
///
1061+
/// NOTE: This may return false for defer statements that have been
1062+
/// deserialized without a DeclContext. This means that this is guaranteed to
1063+
/// be correct for SILFunctions in Raw SIL that were not deserialized as
1064+
/// canonical. Thus one can use it for diagnostics.
1065+
bool isDefer() const {
1066+
if (auto *dc = getDeclContext())
1067+
if (auto *decl = dyn_cast_or_null<FuncDecl>(dc->getAsDecl()))
1068+
return decl->isDeferBody();
1069+
return false;
1070+
}
1071+
10591072
//===--------------------------------------------------------------------===//
10601073
// Block List Access
10611074
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)