mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge remote-tracking branch 'origin/master' into master-next
This commit is contained in:
@@ -789,10 +789,10 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
std::unique_ptr<DelayedParsingCallbacks> DelayedCB{
|
||||
computeDelayedParsingCallback()};
|
||||
|
||||
PersistentParserState PersistentState(getASTContext());
|
||||
PersistentState = llvm::make_unique<PersistentParserState>(getASTContext());
|
||||
|
||||
bool hadLoadError = parsePartialModulesAndLibraryFiles(
|
||||
implicitImports, PersistentState, DelayedCB.get());
|
||||
implicitImports, DelayedCB.get());
|
||||
if (Invocation.isCodeCompletion()) {
|
||||
// When we are doing code completion, make sure to emit at least one
|
||||
// diagnostic, so that ASTContext is marked as erroneous. In this case
|
||||
@@ -810,8 +810,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
// In addition, the main file has parsing and type-checking
|
||||
// interwined.
|
||||
if (MainBufferID != NO_SUCH_BUFFER) {
|
||||
parseAndTypeCheckMainFileUpTo(limitStage, PersistentState,
|
||||
DelayedCB.get(), TypeCheckOptions);
|
||||
parseAndTypeCheckMainFileUpTo(limitStage, DelayedCB.get(), TypeCheckOptions);
|
||||
}
|
||||
|
||||
assert(llvm::all_of(MainModule->getFiles(), [](const FileUnit *File) -> bool {
|
||||
@@ -829,7 +828,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
|
||||
const auto &options = Invocation.getFrontendOptions();
|
||||
forEachFileToTypeCheck([&](SourceFile &SF) {
|
||||
performTypeChecking(SF, PersistentState.getTopLevelContext(),
|
||||
performTypeChecking(SF, PersistentState->getTopLevelContext(),
|
||||
TypeCheckOptions, /*curElem*/ 0,
|
||||
options.WarnLongFunctionBodies,
|
||||
options.WarnLongExpressionTypeChecking,
|
||||
@@ -837,7 +836,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
options.SwitchCheckingInvocationThreshold);
|
||||
|
||||
if (!Context->hadError() && Invocation.getFrontendOptions().PCMacro) {
|
||||
performPCMacro(SF, PersistentState.getTopLevelContext());
|
||||
performPCMacro(SF, PersistentState->getTopLevelContext());
|
||||
}
|
||||
|
||||
// Playground transform knows to look out for PCMacro's changes and not
|
||||
@@ -850,7 +849,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
});
|
||||
|
||||
if (Invocation.isCodeCompletion()) {
|
||||
performDelayedParsing(MainModule, PersistentState,
|
||||
performDelayedParsing(MainModule, *PersistentState.get(),
|
||||
Invocation.getCodeCompletionFactory());
|
||||
}
|
||||
finishTypeChecking(TypeCheckOptions);
|
||||
@@ -858,7 +857,6 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
|
||||
void CompilerInstance::parseLibraryFile(
|
||||
unsigned BufferID, const ImplicitImports &implicitImports,
|
||||
PersistentParserState &PersistentState,
|
||||
DelayedParsingCallbacks *DelayedCB) {
|
||||
FrontendStatsTracer tracer(Context->Stats, "parse-library-file");
|
||||
|
||||
@@ -876,8 +874,9 @@ void CompilerInstance::parseLibraryFile(
|
||||
do {
|
||||
// Parser may stop at some erroneous constructions like #else, #endif
|
||||
// or '}' in some cases, continue parsing until we are done
|
||||
parseIntoSourceFile(*NextInput, BufferID, &Done, nullptr, &PersistentState,
|
||||
DelayedCB, /*DelayedBodyParsing=*/!IsPrimary);
|
||||
parseIntoSourceFile(*NextInput, BufferID, &Done, nullptr,
|
||||
PersistentState.get(), DelayedCB,
|
||||
/*DelayedBodyParsing=*/!IsPrimary);
|
||||
} while (!Done);
|
||||
|
||||
Diags.setSuppressWarnings(DidSuppressWarnings);
|
||||
@@ -905,7 +904,6 @@ OptionSet<TypeCheckingFlags> CompilerInstance::computeTypeCheckingOptions() {
|
||||
|
||||
bool CompilerInstance::parsePartialModulesAndLibraryFiles(
|
||||
const ImplicitImports &implicitImports,
|
||||
PersistentParserState &PersistentState,
|
||||
DelayedParsingCallbacks *DelayedCB) {
|
||||
FrontendStatsTracer tracer(Context->Stats,
|
||||
"parse-partial-modules-and-library-files");
|
||||
@@ -922,7 +920,7 @@ bool CompilerInstance::parsePartialModulesAndLibraryFiles(
|
||||
// Then parse all the library files.
|
||||
for (auto BufferID : InputSourceCodeBufferIDs) {
|
||||
if (BufferID != MainBufferID) {
|
||||
parseLibraryFile(BufferID, implicitImports, PersistentState, DelayedCB);
|
||||
parseLibraryFile(BufferID, implicitImports, DelayedCB);
|
||||
}
|
||||
}
|
||||
return hadLoadError;
|
||||
@@ -930,7 +928,6 @@ bool CompilerInstance::parsePartialModulesAndLibraryFiles(
|
||||
|
||||
void CompilerInstance::parseAndTypeCheckMainFileUpTo(
|
||||
SourceFile::ASTStage_t LimitStage,
|
||||
PersistentParserState &PersistentState,
|
||||
DelayedParsingCallbacks *DelayedParseCB,
|
||||
OptionSet<TypeCheckingFlags> TypeCheckOptions) {
|
||||
FrontendStatsTracer tracer(Context->Stats,
|
||||
@@ -954,8 +951,9 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
|
||||
// there are chunks of swift decls (e.g. imports and types) interspersed
|
||||
// with 'sil' definitions.
|
||||
parseIntoSourceFile(MainFile, MainFile.getBufferID().getValue(), &Done,
|
||||
TheSILModule ? &SILContext : nullptr, &PersistentState,
|
||||
DelayedParseCB, /*DelayedBodyParsing=*/false);
|
||||
TheSILModule ? &SILContext : nullptr,
|
||||
PersistentState.get(), DelayedParseCB,
|
||||
/*DelayedBodyParsing=*/false);
|
||||
|
||||
if (mainIsPrimary && (Done || CurTUElem < MainFile.Decls.size())) {
|
||||
switch (LimitStage) {
|
||||
@@ -967,7 +965,7 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
|
||||
break;
|
||||
case SourceFile::TypeChecked:
|
||||
const auto &options = Invocation.getFrontendOptions();
|
||||
performTypeChecking(MainFile, PersistentState.getTopLevelContext(),
|
||||
performTypeChecking(MainFile, PersistentState->getTopLevelContext(),
|
||||
TypeCheckOptions, CurTUElem,
|
||||
options.WarnLongFunctionBodies,
|
||||
options.WarnLongExpressionTypeChecking,
|
||||
@@ -1062,12 +1060,13 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
MainBufferID);
|
||||
}
|
||||
|
||||
PersistentParserState PersistentState(getASTContext());
|
||||
PersistentState = llvm::make_unique<PersistentParserState>(getASTContext());
|
||||
|
||||
SWIFT_DEFER {
|
||||
if (ParseDelayedBodyOnEnd)
|
||||
PersistentState.parseAllDelayedDeclLists();
|
||||
PersistentState->parseAllDelayedDeclLists();
|
||||
};
|
||||
PersistentState.PerformConditionEvaluation = EvaluateConditionals;
|
||||
PersistentState->PerformConditionEvaluation = EvaluateConditionals;
|
||||
// Parse all the library files.
|
||||
for (auto BufferID : InputSourceCodeBufferIDs) {
|
||||
if (BufferID == MainBufferID)
|
||||
@@ -1079,7 +1078,7 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
SourceFileKind::Library, SourceFile::ImplicitModuleImportKind::None,
|
||||
BufferID);
|
||||
|
||||
parseIntoSourceFileFull(*NextInput, BufferID, &PersistentState,
|
||||
parseIntoSourceFileFull(*NextInput, BufferID, PersistentState.get(),
|
||||
nullptr, /*DelayBodyParsing=*/!IsPrimary);
|
||||
}
|
||||
|
||||
@@ -1090,7 +1089,7 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
MainFile.SyntaxParsingCache = Invocation.getMainFileSyntaxParsingCache();
|
||||
|
||||
parseIntoSourceFileFull(MainFile, MainFile.getBufferID().getValue(),
|
||||
&PersistentState, nullptr,
|
||||
PersistentState.get(), nullptr,
|
||||
/*DelayBodyParsing=*/false);
|
||||
}
|
||||
|
||||
@@ -1099,6 +1098,7 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
}
|
||||
|
||||
void CompilerInstance::freeASTContext() {
|
||||
PersistentState.reset();
|
||||
Context.reset();
|
||||
MainModule = nullptr;
|
||||
SML = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user