mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/master' into master-rebranch
This commit is contained in:
@@ -1071,7 +1071,7 @@ SourceFile *CompilerInstance::createSourceFileForMainModule(
|
||||
}
|
||||
|
||||
void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
bool ParseDelayedBodyOnEnd) {
|
||||
bool CanDelayBodies) {
|
||||
const InputFileKind Kind = Invocation.getInputKind();
|
||||
ModuleDecl *const MainModule = getMainModule();
|
||||
Context->LoadedModules[MainModule->getName()] = MainModule;
|
||||
@@ -1093,25 +1093,27 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
}
|
||||
|
||||
PersistentState = std::make_unique<PersistentParserState>();
|
||||
|
||||
SWIFT_DEFER {
|
||||
if (ParseDelayedBodyOnEnd)
|
||||
PersistentState->parseAllDelayedDeclLists();
|
||||
};
|
||||
PersistentState->PerformConditionEvaluation = EvaluateConditionals;
|
||||
|
||||
auto shouldDelayBodies = [&](unsigned bufferID) -> bool {
|
||||
if (!CanDelayBodies)
|
||||
return false;
|
||||
|
||||
// Don't delay bodies in whole module mode or for primary files.
|
||||
return !(isWholeModuleCompilation() || isPrimaryInput(bufferID));
|
||||
};
|
||||
|
||||
// Parse all the library files.
|
||||
for (auto BufferID : InputSourceCodeBufferIDs) {
|
||||
if (BufferID == MainBufferID)
|
||||
continue;
|
||||
|
||||
auto IsPrimary = isWholeModuleCompilation() || isPrimaryInput(BufferID);
|
||||
|
||||
SourceFile *NextInput = createSourceFileForMainModule(
|
||||
SourceFileKind::Library, SourceFile::ImplicitModuleImportKind::None,
|
||||
BufferID);
|
||||
|
||||
parseIntoSourceFileFull(*NextInput, BufferID, PersistentState.get(),
|
||||
/*DelayBodyParsing=*/!IsPrimary);
|
||||
shouldDelayBodies(BufferID));
|
||||
}
|
||||
|
||||
// Now parse the main file.
|
||||
@@ -1119,10 +1121,10 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
SourceFile &MainFile =
|
||||
MainModule->getMainSourceFile(Invocation.getSourceFileKind());
|
||||
MainFile.SyntaxParsingCache = Invocation.getMainFileSyntaxParsingCache();
|
||||
assert(MainBufferID == MainFile.getBufferID());
|
||||
|
||||
parseIntoSourceFileFull(MainFile, MainFile.getBufferID().getValue(),
|
||||
PersistentState.get(),
|
||||
/*DelayBodyParsing=*/false);
|
||||
parseIntoSourceFileFull(MainFile, MainBufferID, PersistentState.get(),
|
||||
shouldDelayBodies(MainBufferID));
|
||||
}
|
||||
|
||||
assert(Context->LoadedModules.size() == 1 &&
|
||||
|
||||
Reference in New Issue
Block a user