[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.
This commit is contained in:
Michael Gottesman
2021-12-30 14:47:09 -08:00
parent 5dc8b3879b
commit fe6e3f9a90

View File

@@ -1056,6 +1056,19 @@ public:
/// generic.
SubstitutionMap getForwardingSubstitutionMap();
/// Returns true if this SILFunction must be a defer statement.
///
/// 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.
bool isDefer() const {
if (auto *dc = getDeclContext())
if (auto *decl = dyn_cast_or_null<FuncDecl>(dc->getAsDecl()))
return decl->isDeferBody();
return false;
}
//===--------------------------------------------------------------------===//
// Block List Access
//===--------------------------------------------------------------------===//