mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Requestify ExportedSourceFile parsing
Avoid parsing the syntax tree up-front, and instead only parse it when required, which happens when either: 1. ASTGen parsing is enabled (currently disabled by default) 2. Round trip checking is enabled for a primary file (enabled by default in a debug build, except when dep scanning or doing an IDE operation) 3. We need to evaluate a macro in that file This change therefore means that we now no longer need to parse the syntax tree for secondary files by default unless we specifically need to evaluate a macro in them (e.g if we need to lookup a member on a decl with an attached macro). And the same for primaries in release builds. rdar://109283847
This commit is contained in:
@@ -3687,6 +3687,10 @@ SourceFile::getDefaultParsingOptions(const LangOptions &langOpts) {
|
||||
opts |= ParsingFlags::DisablePoundIfEvaluation;
|
||||
if (langOpts.CollectParsedToken)
|
||||
opts |= ParsingFlags::CollectParsedTokens;
|
||||
if (langOpts.hasFeature(Feature::ParserRoundTrip))
|
||||
opts |= ParsingFlags::RoundTrip;
|
||||
if (langOpts.hasFeature(Feature::ParserValidation))
|
||||
opts |= ParsingFlags::ValidateNewParserDiagnostics;
|
||||
return opts;
|
||||
}
|
||||
|
||||
@@ -3762,6 +3766,11 @@ ArrayRef<Decl *> SourceFile::getHoistedDecls() const {
|
||||
return Hoisted;
|
||||
}
|
||||
|
||||
void *SourceFile::getExportedSourceFile() const {
|
||||
auto &eval = getASTContext().evaluator;
|
||||
return evaluateOrDefault(eval, ExportedSourceFileRequest{this}, nullptr);
|
||||
}
|
||||
|
||||
void SourceFile::addDeclWithRuntimeDiscoverableAttrs(ValueDecl *decl) {
|
||||
assert(!decl->getRuntimeDiscoverableAttrs().empty());
|
||||
DeclsWithRuntimeDiscoverableAttrs.insert(decl);
|
||||
|
||||
Reference in New Issue
Block a user