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:
@@ -294,15 +294,6 @@ past that, so:
|
||||
All the same options from above apply, but you'll have to manually deal
|
||||
with the work the compiler would have done automatically for you.
|
||||
|
||||
- Invoke `swiftc -c` with `-###`. Then run all of the outputted commands
|
||||
that include `-primary-file`, then run the remaining commands in order
|
||||
(they may have dependencies). If none of the commands have `-primary-file`
|
||||
in them, they're not parallelizable, sorry.
|
||||
|
||||
This is the most hacky approach, because (a) it involves looking for an
|
||||
internal flag in a non-stable interface, and (b) you don't get anything
|
||||
incremental out of this. We could stand some improvements here.
|
||||
|
||||
Whatever you do, do *not* invoke the frontend directly.
|
||||
|
||||
|
||||
|
||||
@@ -139,10 +139,27 @@ namespace swift {
|
||||
/// Allow throwing call expressions without annotation with 'try'.
|
||||
bool EnableThrowWithoutTry = false;
|
||||
|
||||
/// If set, inserts instrumentation useful for testing the debugger.
|
||||
bool DebuggerTestingTransform = false;
|
||||
|
||||
/// Indicates whether the AST should be instrumented to simulate a
|
||||
/// debugger's program counter. Similar to the PlaygroundTransform, this
|
||||
/// will instrument the AST with function calls that get called when you
|
||||
/// would see a program counter move in a debugger. To adopt this implement
|
||||
/// the __builtin_pc_before and __builtin_pc_after functions.
|
||||
bool PCMacro = false;
|
||||
|
||||
/// Enable features useful for running playgrounds.
|
||||
// FIXME: This should probably be limited to the particular SourceFile.
|
||||
bool Playground = false;
|
||||
|
||||
/// Indicates whether the playground transformation should be applied.
|
||||
bool PlaygroundTransform = false;
|
||||
|
||||
/// Indicates whether the playground transformation should omit
|
||||
/// instrumentation that has a high runtime performance impact.
|
||||
bool PlaygroundHighPerformance = false;
|
||||
|
||||
/// Keep comments during lexing and attach them to declarations.
|
||||
bool AttachCommentsToDecls = false;
|
||||
|
||||
|
||||
@@ -671,7 +671,6 @@ private:
|
||||
ImplicitImportInfo getImplicitImportInfo() const;
|
||||
|
||||
void performSemaUpTo(SourceFile::ASTStage_t LimitStage);
|
||||
void parseAndCheckTypesUpTo(SourceFile::ASTStage_t LimitStage);
|
||||
|
||||
/// Return true if had load error
|
||||
bool parsePartialModulesAndInputFiles();
|
||||
|
||||
@@ -154,9 +154,6 @@ public:
|
||||
/// the module.
|
||||
bool CheckOnoneSupportCompleteness = false;
|
||||
|
||||
/// If set, inserts instrumentation useful for testing the debugger.
|
||||
bool DebuggerTestingTransform = false;
|
||||
|
||||
/// If set, dumps wall time taken to check each function body to llvm::errs().
|
||||
bool DebugTimeFunctionBodies = false;
|
||||
|
||||
@@ -223,20 +220,6 @@ public:
|
||||
/// termination.
|
||||
bool PrintClangStats = false;
|
||||
|
||||
/// Indicates whether the playground transformation should be applied.
|
||||
bool PlaygroundTransform = false;
|
||||
|
||||
/// Indicates whether the AST should be instrumented to simulate a debugger's
|
||||
/// program counter. Similar to the PlaygroundTransform, this will instrument
|
||||
/// the AST with function calls that get called when you would see a program
|
||||
/// counter move in a debugger. To adopt this implement the
|
||||
/// __builtin_pc_before and __builtin_pc_after functions.
|
||||
bool PCMacro = false;
|
||||
|
||||
/// Indicates whether the playground transformation should omit
|
||||
/// instrumentation that has a high runtime performance impact.
|
||||
bool PlaygroundHighPerformance = false;
|
||||
|
||||
/// Indicates whether standard help should be shown.
|
||||
bool PrintHelp = false;
|
||||
|
||||
|
||||
@@ -103,13 +103,6 @@ bool ArgsToFrontendOptionsConverter::convert(
|
||||
|
||||
Opts.CheckOnoneSupportCompleteness = Args.hasArg(OPT_check_onone_completeness);
|
||||
|
||||
Opts.DebuggerTestingTransform = Args.hasArg(OPT_debugger_testing_transform);
|
||||
|
||||
computePlaygroundOptions();
|
||||
|
||||
// This can be enabled independently of the playground transform.
|
||||
Opts.PCMacro |= Args.hasArg(OPT_pc_macro);
|
||||
|
||||
Opts.ParseStdlib |= Args.hasArg(OPT_parse_stdlib);
|
||||
|
||||
Opts.IgnoreSwiftSourceInfo |= Args.hasArg(OPT_ignore_module_source_info);
|
||||
@@ -261,15 +254,6 @@ void ArgsToFrontendOptionsConverter::computeTBDOptions() {
|
||||
}
|
||||
}
|
||||
|
||||
void ArgsToFrontendOptionsConverter::computePlaygroundOptions() {
|
||||
using namespace options;
|
||||
Opts.PlaygroundTransform |= Args.hasArg(OPT_playground);
|
||||
if (Args.hasArg(OPT_disable_playground_transform))
|
||||
Opts.PlaygroundTransform = false;
|
||||
Opts.PlaygroundHighPerformance |=
|
||||
Args.hasArg(OPT_playground_high_performance);
|
||||
}
|
||||
|
||||
void ArgsToFrontendOptionsConverter::computeHelpOptions() {
|
||||
using namespace options;
|
||||
if (const Arg *A = Args.getLastArg(OPT_help, OPT_help_hidden)) {
|
||||
|
||||
@@ -451,7 +451,19 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
||||
Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support);
|
||||
if (Opts.DebuggerSupport)
|
||||
Opts.EnableDollarIdentifiers = true;
|
||||
|
||||
Opts.DebuggerTestingTransform = Args.hasArg(OPT_debugger_testing_transform);
|
||||
|
||||
Opts.Playground |= Args.hasArg(OPT_playground);
|
||||
Opts.PlaygroundTransform |= Args.hasArg(OPT_playground);
|
||||
if (Args.hasArg(OPT_disable_playground_transform))
|
||||
Opts.PlaygroundTransform = false;
|
||||
Opts.PlaygroundHighPerformance |=
|
||||
Args.hasArg(OPT_playground_high_performance);
|
||||
|
||||
// This can be enabled independently of the playground transform.
|
||||
Opts.PCMacro |= Args.hasArg(OPT_pc_macro);
|
||||
|
||||
Opts.InferImportAsMember |= Args.hasArg(OPT_enable_infer_import_as_member);
|
||||
|
||||
Opts.EnableThrowWithoutTry |= Args.hasArg(OPT_enable_throw_without_try);
|
||||
|
||||
@@ -794,7 +794,40 @@ void CompilerInstance::performSemaUpTo(SourceFile::ASTStage_t LimitStage) {
|
||||
MainBufferID);
|
||||
}
|
||||
|
||||
parseAndCheckTypesUpTo(LimitStage);
|
||||
bool hadLoadError = parsePartialModulesAndInputFiles();
|
||||
if (hadLoadError)
|
||||
return;
|
||||
|
||||
assert(llvm::all_of(MainModule->getFiles(), [](const FileUnit *File) -> bool {
|
||||
auto *SF = dyn_cast<SourceFile>(File);
|
||||
if (!SF)
|
||||
return true;
|
||||
return SF->ASTStage >= SourceFile::ImportsResolved;
|
||||
}) && "some files have not yet had their imports resolved");
|
||||
MainModule->setHasResolvedImports();
|
||||
|
||||
forEachFileToTypeCheck([&](SourceFile &SF) {
|
||||
if (LimitStage == SourceFile::ImportsResolved) {
|
||||
bindExtensions(SF);
|
||||
return;
|
||||
}
|
||||
|
||||
performTypeChecking(SF);
|
||||
|
||||
// Parse the SIL decls if needed.
|
||||
// TODO: Requestify SIL parsing.
|
||||
if (TheSILModule) {
|
||||
SILParserState SILContext(TheSILModule.get());
|
||||
parseSourceFileSIL(SF, &SILContext);
|
||||
}
|
||||
});
|
||||
|
||||
// If the limiting AST stage is import resolution, we're done.
|
||||
if (LimitStage <= SourceFile::ImportsResolved) {
|
||||
return;
|
||||
}
|
||||
|
||||
finishTypeChecking();
|
||||
}
|
||||
|
||||
bool CompilerInstance::loadStdlib() {
|
||||
@@ -816,58 +849,6 @@ bool CompilerInstance::loadStdlib() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CompilerInstance::parseAndCheckTypesUpTo(
|
||||
SourceFile::ASTStage_t limitStage) {
|
||||
FrontendStatsTracer tracer(getStatsReporter(), "parse-and-check-types");
|
||||
|
||||
bool hadLoadError = parsePartialModulesAndInputFiles();
|
||||
if (hadLoadError)
|
||||
return;
|
||||
|
||||
assert(llvm::all_of(MainModule->getFiles(), [](const FileUnit *File) -> bool {
|
||||
auto *SF = dyn_cast<SourceFile>(File);
|
||||
if (!SF)
|
||||
return true;
|
||||
return SF->ASTStage >= SourceFile::ImportsResolved;
|
||||
}) && "some files have not yet had their imports resolved");
|
||||
MainModule->setHasResolvedImports();
|
||||
|
||||
forEachFileToTypeCheck([&](SourceFile &SF) {
|
||||
if (limitStage == SourceFile::ImportsResolved) {
|
||||
bindExtensions(SF);
|
||||
return;
|
||||
}
|
||||
|
||||
performTypeChecking(SF);
|
||||
|
||||
// Parse the SIL decls if needed.
|
||||
// TODO: Requestify SIL parsing.
|
||||
if (TheSILModule) {
|
||||
SILParserState SILContext(TheSILModule.get());
|
||||
parseSourceFileSIL(SF, &SILContext);
|
||||
}
|
||||
|
||||
auto &opts = Invocation.getFrontendOptions();
|
||||
if (!Context->hadError() && opts.DebuggerTestingTransform)
|
||||
performDebuggerTestingTransform(SF);
|
||||
|
||||
if (!Context->hadError() && opts.PCMacro)
|
||||
performPCMacro(SF);
|
||||
|
||||
// Playground transform knows to look out for PCMacro's changes and not
|
||||
// to playground log them.
|
||||
if (!Context->hadError() && opts.PlaygroundTransform)
|
||||
performPlaygroundTransform(SF, opts.PlaygroundHighPerformance);
|
||||
});
|
||||
|
||||
// If the limiting AST stage is import resolution, we're done.
|
||||
if (limitStage <= SourceFile::ImportsResolved) {
|
||||
return;
|
||||
}
|
||||
|
||||
finishTypeChecking();
|
||||
}
|
||||
|
||||
bool CompilerInstance::parsePartialModulesAndInputFiles() {
|
||||
FrontendStatsTracer tracer(getStatsReporter(),
|
||||
"parse-partial-modules-and-input-files");
|
||||
|
||||
@@ -382,6 +382,18 @@ TypeCheckSourceFileRequest::evaluate(Evaluator &eval, SourceFile *SF) const {
|
||||
performWholeModuleTypeChecking(*SF);
|
||||
}
|
||||
|
||||
// Perform various AST transforms we've been asked to perform.
|
||||
if (!Ctx.hadError() && Ctx.LangOpts.DebuggerTestingTransform)
|
||||
performDebuggerTestingTransform(*SF);
|
||||
|
||||
if (!Ctx.hadError() && Ctx.LangOpts.PCMacro)
|
||||
performPCMacro(*SF);
|
||||
|
||||
// Playground transform knows to look out for PCMacro's changes and not
|
||||
// to playground log them.
|
||||
if (!Ctx.hadError() && Ctx.LangOpts.PlaygroundTransform)
|
||||
performPlaygroundTransform(*SF, Ctx.LangOpts.PlaygroundHighPerformance);
|
||||
|
||||
return std::make_tuple<>();
|
||||
}
|
||||
|
||||
|
||||
@@ -520,19 +520,21 @@ bool SwiftASTManager::initCompilerInvocation(
|
||||
ImporterOpts.DetailedPreprocessingRecord = true;
|
||||
|
||||
assert(!Invocation.getModuleName().empty());
|
||||
Invocation.getLangOptions().AttachCommentsToDecls = true;
|
||||
Invocation.getLangOptions().DiagnosticsEditorMode = true;
|
||||
Invocation.getLangOptions().CollectParsedToken = true;
|
||||
auto &FrontendOpts = Invocation.getFrontendOptions();
|
||||
if (FrontendOpts.PlaygroundTransform) {
|
||||
|
||||
auto &LangOpts = Invocation.getLangOptions();
|
||||
LangOpts.AttachCommentsToDecls = true;
|
||||
LangOpts.DiagnosticsEditorMode = true;
|
||||
LangOpts.CollectParsedToken = true;
|
||||
if (LangOpts.PlaygroundTransform) {
|
||||
// The playground instrumenter changes the AST in ways that disrupt the
|
||||
// SourceKit functionality. Since we don't need the instrumenter, and all we
|
||||
// actually need is the playground semantics visible to the user, like
|
||||
// silencing the "expression resolves to an unused l-value" error, disable it.
|
||||
FrontendOpts.PlaygroundTransform = false;
|
||||
LangOpts.PlaygroundTransform = false;
|
||||
}
|
||||
|
||||
// Disable the index-store functionality for the sourcekitd requests.
|
||||
auto &FrontendOpts = Invocation.getFrontendOptions();
|
||||
FrontendOpts.IndexStorePath.clear();
|
||||
ImporterOpts.IndexStorePath.clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user