[Parse] Check the SourceFile to see if bodies can be delayed

Remove the `DelayBodyParsing` flag from the parser
and instead query the source file.
This commit is contained in:
Hamish Knight
2020-02-11 15:30:34 -08:00
parent 2ec619caf7
commit 2724cf6f65
8 changed files with 53 additions and 62 deletions

View File

@@ -1954,6 +1954,23 @@ bool SourceFile::canBeParsedInFull() const {
llvm_unreachable("unhandled kind");
}
bool SourceFile::hasDelayedBodyParsing() const {
if (ParsingOpts.contains(ParsingFlags::DisableDelayedBodies))
return false;
// Not supported right now.
if (Kind == SourceFileKind::REPL || Kind == SourceFileKind::SIL)
return false;
if (hasInterfaceHash())
return false;
if (shouldCollectToken())
return false;
if (shouldBuildSyntaxTree())
return false;
return true;
}
bool FileUnit::walk(ASTWalker &walker) {
SmallVector<Decl *, 64> Decls;
getTopLevelDecls(Decls);