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-next
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
#include "swift/Basic/SourceManager.h"
|
||||
#include "swift/Basic/Statistic.h"
|
||||
#include "swift/Frontend/ParseableInterfaceModuleLoader.h"
|
||||
#include "swift/Parse/DelayedParsingCallbacks.h"
|
||||
#include "swift/Parse/Lexer.h"
|
||||
#include "swift/SIL/SILModule.h"
|
||||
#include "swift/SILOptimizer/PassManager/Passes.h"
|
||||
@@ -755,14 +754,6 @@ void CompilerInstance::createREPLFile(const ImplicitImports &implicitImports) {
|
||||
addAdditionalInitialImportsTo(SingleInputFile, implicitImports);
|
||||
}
|
||||
|
||||
std::unique_ptr<DelayedParsingCallbacks>
|
||||
CompilerInstance::computeDelayedParsingCallback() {
|
||||
if (Invocation.isCodeCompletion())
|
||||
return std::make_unique<CodeCompleteDelayedCallbacks>(
|
||||
SourceMgr.getCodeCompletionLoc());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CompilerInstance::addMainFileToModule(
|
||||
const ImplicitImports &implicitImports) {
|
||||
auto *MainFile = createSourceFileForMainModule(
|
||||
@@ -773,13 +764,10 @@ void CompilerInstance::addMainFileToModule(
|
||||
void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
const ImplicitImports &implicitImports, SourceFile::ASTStage_t limitStage) {
|
||||
FrontendStatsTracer tracer(Context->Stats, "parse-and-check-types");
|
||||
std::unique_ptr<DelayedParsingCallbacks> DelayedCB{
|
||||
computeDelayedParsingCallback()};
|
||||
|
||||
PersistentState = std::make_unique<PersistentParserState>();
|
||||
|
||||
bool hadLoadError = parsePartialModulesAndLibraryFiles(
|
||||
implicitImports, DelayedCB.get());
|
||||
bool hadLoadError = parsePartialModulesAndLibraryFiles(implicitImports);
|
||||
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
|
||||
@@ -797,7 +785,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
// In addition, the main file has parsing and type-checking
|
||||
// interwined.
|
||||
if (MainBufferID != NO_SUCH_BUFFER) {
|
||||
parseAndTypeCheckMainFileUpTo(limitStage, DelayedCB.get(), TypeCheckOptions);
|
||||
parseAndTypeCheckMainFileUpTo(limitStage, TypeCheckOptions);
|
||||
}
|
||||
|
||||
assert(llvm::all_of(MainModule->getFiles(), [](const FileUnit *File) -> bool {
|
||||
@@ -843,8 +831,7 @@ void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
}
|
||||
|
||||
void CompilerInstance::parseLibraryFile(
|
||||
unsigned BufferID, const ImplicitImports &implicitImports,
|
||||
DelayedParsingCallbacks *DelayedCB) {
|
||||
unsigned BufferID, const ImplicitImports &implicitImports) {
|
||||
FrontendStatsTracer tracer(Context->Stats, "parse-library-file");
|
||||
|
||||
auto *NextInput = createSourceFileForMainModule(
|
||||
@@ -862,7 +849,7 @@ void CompilerInstance::parseLibraryFile(
|
||||
// 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.get(), DelayedCB,
|
||||
PersistentState.get(),
|
||||
/*DelayedBodyParsing=*/!IsPrimary);
|
||||
} while (!Done);
|
||||
|
||||
@@ -890,8 +877,7 @@ OptionSet<TypeCheckingFlags> CompilerInstance::computeTypeCheckingOptions() {
|
||||
}
|
||||
|
||||
bool CompilerInstance::parsePartialModulesAndLibraryFiles(
|
||||
const ImplicitImports &implicitImports,
|
||||
DelayedParsingCallbacks *DelayedCB) {
|
||||
const ImplicitImports &implicitImports) {
|
||||
FrontendStatsTracer tracer(Context->Stats,
|
||||
"parse-partial-modules-and-library-files");
|
||||
bool hadLoadError = false;
|
||||
@@ -907,7 +893,7 @@ bool CompilerInstance::parsePartialModulesAndLibraryFiles(
|
||||
// Then parse all the library files.
|
||||
for (auto BufferID : InputSourceCodeBufferIDs) {
|
||||
if (BufferID != MainBufferID) {
|
||||
parseLibraryFile(BufferID, implicitImports, DelayedCB);
|
||||
parseLibraryFile(BufferID, implicitImports);
|
||||
}
|
||||
}
|
||||
return hadLoadError;
|
||||
@@ -915,7 +901,6 @@ bool CompilerInstance::parsePartialModulesAndLibraryFiles(
|
||||
|
||||
void CompilerInstance::parseAndTypeCheckMainFileUpTo(
|
||||
SourceFile::ASTStage_t LimitStage,
|
||||
DelayedParsingCallbacks *DelayedParseCB,
|
||||
OptionSet<TypeCheckingFlags> TypeCheckOptions) {
|
||||
FrontendStatsTracer tracer(Context->Stats,
|
||||
"parse-and-typecheck-main-file");
|
||||
@@ -939,7 +924,7 @@ void CompilerInstance::parseAndTypeCheckMainFileUpTo(
|
||||
// with 'sil' definitions.
|
||||
parseIntoSourceFile(MainFile, MainFile.getBufferID().getValue(), &Done,
|
||||
TheSILModule ? &SILContext : nullptr,
|
||||
PersistentState.get(), DelayedParseCB,
|
||||
PersistentState.get(),
|
||||
/*DelayedBodyParsing=*/false);
|
||||
|
||||
if (mainIsPrimary && (Done || CurTUElem < MainFile.Decls.size())) {
|
||||
@@ -1066,7 +1051,7 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
BufferID);
|
||||
|
||||
parseIntoSourceFileFull(*NextInput, BufferID, PersistentState.get(),
|
||||
nullptr, /*DelayBodyParsing=*/!IsPrimary);
|
||||
/*DelayBodyParsing=*/!IsPrimary);
|
||||
}
|
||||
|
||||
// Now parse the main file.
|
||||
@@ -1076,7 +1061,7 @@ void CompilerInstance::performParseOnly(bool EvaluateConditionals,
|
||||
MainFile.SyntaxParsingCache = Invocation.getMainFileSyntaxParsingCache();
|
||||
|
||||
parseIntoSourceFileFull(MainFile, MainFile.getBufferID().getValue(),
|
||||
PersistentState.get(), nullptr,
|
||||
PersistentState.get(),
|
||||
/*DelayBodyParsing=*/false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user