Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class FrontendOptions {
NoneAction, ///< No specific action
Parse, ///< Parse only
ResolveImports, ///< Parse and resolve imports only
LazyTypecheck, ///< Parse and then do minimal type-checking for outputs
Typecheck, ///< Parse and type-check only
DumpParse, ///< Parse only and dump AST
DumpInterfaceHash, ///< Parse and dump the interface token hash.
Expand Down
3 changes: 3 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,9 @@ def resolve_imports : Flag<["-"], "resolve-imports">,
def typecheck : Flag<["-"], "typecheck">,
HelpText<"Parse and type-check input file(s)">, ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
def experimental_lazy_typecheck : Flag<["-"], "experimental-lazy-typecheck">,
HelpText<"Parse input file(s), then type-check lazily as needed to produce requested outputs">, ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, HelpHidden, DoesNotAffectIncrementalBuild]>;
def dump_parse : Flag<["-"], "dump-parse">,
HelpText<"Parse input file(s) and dump AST(s)">, ModeOpt,
Flags<[FrontendOption, NoInteractiveOption, DoesNotAffectIncrementalBuild]>;
Expand Down
1 change: 1 addition & 0 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,7 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,

case options::OPT_parse:
case options::OPT_resolve_imports:
case options::OPT_experimental_lazy_typecheck:
case options::OPT_typecheck:
case options::OPT_dump_parse:
case options::OPT_print_ast:
Expand Down
2 changes: 2 additions & 0 deletions lib/Frontend/ArgsToFrontendOptionsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,8 @@ ArgsToFrontendOptionsConverter::determineRequestedAction(const ArgList &args) {
return FrontendOptions::ActionType::Parse;
if (Opt.matches(OPT_resolve_imports))
return FrontendOptions::ActionType::ResolveImports;
if (Opt.matches(OPT_experimental_lazy_typecheck))
return FrontendOptions::ActionType::LazyTypecheck;
if (Opt.matches(OPT_typecheck))
return FrontendOptions::ActionType::Typecheck;
if (Opt.matches(OPT_dump_parse))
Expand Down
19 changes: 19 additions & 0 deletions lib/Frontend/FrontendOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ bool FrontendOptions::needsProperModuleName(ActionType action) {
case ActionType::NoneAction:
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpParse:
case ActionType::DumpAST:
Expand Down Expand Up @@ -104,6 +105,7 @@ bool FrontendOptions::doesActionRequireSwiftStandardLibrary(ActionType action) {
case ActionType::PrintFeature:
return false;
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpAST:
case ActionType::PrintAST:
Expand Down Expand Up @@ -149,6 +151,7 @@ bool FrontendOptions::doesActionRequireInputs(ActionType action) {
case ActionType::CompileModuleFromInterface:
case ActionType::TypecheckModuleFromInterface:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpAST:
case ActionType::PrintAST:
Expand Down Expand Up @@ -191,6 +194,7 @@ bool FrontendOptions::doesActionPerformEndOfPipelineActions(ActionType action) {
case ActionType::CompileModuleFromInterface:
case ActionType::TypecheckModuleFromInterface:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpAST:
case ActionType::PrintAST:
Expand Down Expand Up @@ -230,6 +234,7 @@ bool FrontendOptions::supportCompilationCaching(ActionType action) {
case ActionType::EmitImportedModules:
case ActionType::ScanDependencies:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpAST:
case ActionType::PrintAST:
Expand Down Expand Up @@ -290,6 +295,7 @@ FrontendOptions::formatForPrincipalOutputFileForAction(ActionType action) {

case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::TypecheckModuleFromInterface:
case ActionType::DumpParse:
Expand Down Expand Up @@ -377,6 +383,7 @@ bool FrontendOptions::canActionEmitDependencies(ActionType action) {
case ActionType::PrintFeature:
return false;
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::MergeModules:
case ActionType::EmitModuleOnly:
Expand All @@ -403,6 +410,7 @@ bool FrontendOptions::canActionEmitReferenceDependencies(ActionType action) {
case ActionType::NoneAction:
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::DumpParse:
case ActionType::DumpInterfaceHash:
case ActionType::DumpAST:
Expand Down Expand Up @@ -445,6 +453,7 @@ bool FrontendOptions::canActionEmitModuleSummary(ActionType action) {
case ActionType::NoneAction:
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::DumpParse:
case ActionType::DumpInterfaceHash:
case ActionType::DumpAST:
Expand Down Expand Up @@ -506,6 +515,7 @@ bool FrontendOptions::canActionEmitClangHeader(ActionType action) {
case ActionType::PrintVersion:
case ActionType::PrintFeature:
return false;
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::MergeModules:
case ActionType::EmitModuleOnly:
Expand Down Expand Up @@ -547,6 +557,7 @@ bool FrontendOptions::canActionEmitLoadedModuleTrace(ActionType action) {
case ActionType::PrintFeature:
return false;
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::MergeModules:
case ActionType::EmitModuleOnly:
Expand Down Expand Up @@ -576,6 +587,7 @@ bool FrontendOptions::canActionEmitModuleSemanticInfo(ActionType action) {
case ActionType::NoneAction:
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::DumpParse:
case ActionType::DumpInterfaceHash:
case ActionType::DumpAST:
Expand Down Expand Up @@ -619,6 +631,7 @@ bool FrontendOptions::canActionEmitConstValues(ActionType action) {
case ActionType::NoneAction:
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::DumpParse:
case ActionType::DumpInterfaceHash:
case ActionType::DumpAST:
Expand Down Expand Up @@ -660,6 +673,7 @@ bool FrontendOptions::canActionEmitModule(ActionType action) {
case ActionType::NoneAction:
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpParse:
case ActionType::DumpInterfaceHash:
Expand Down Expand Up @@ -727,6 +741,7 @@ bool FrontendOptions::canActionEmitInterface(ActionType action) {
case ActionType::PrintFeature:
return false;
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::MergeModules:
case ActionType::EmitModuleOnly:
Expand All @@ -747,6 +762,7 @@ bool FrontendOptions::doesActionProduceOutput(ActionType action) {
switch (action) {
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpParse:
case ActionType::DumpAST:
Expand Down Expand Up @@ -805,6 +821,7 @@ bool FrontendOptions::doesActionProduceTextualOutput(ActionType action) {

case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpParse:
case ActionType::DumpInterfaceHash:
Expand Down Expand Up @@ -834,6 +851,7 @@ bool FrontendOptions::doesActionGenerateSIL(ActionType action) {
case ActionType::NoneAction:
case ActionType::Parse:
case ActionType::ResolveImports:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::DumpParse:
case ActionType::DumpInterfaceHash:
Expand Down Expand Up @@ -885,6 +903,7 @@ bool FrontendOptions::doesActionGenerateIR(ActionType action) {
case ActionType::DumpTypeInfo:
case ActionType::CompileModuleFromInterface:
case ActionType::TypecheckModuleFromInterface:
case ActionType::LazyTypecheck:
case ActionType::Typecheck:
case ActionType::ResolveImports:
case ActionType::MergeModules:
Expand Down
3 changes: 3 additions & 0 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,9 @@ static bool performAction(CompilerInstance &Instance,
return performParseOnly(*Instance.getMainModule());
case FrontendOptions::ActionType::ResolveImports:
return Instance.performParseAndResolveImportsOnly();
case FrontendOptions::ActionType::LazyTypecheck:
// For now, this action is just an alias of ResolveImports.
return Instance.performParseAndResolveImportsOnly();
case FrontendOptions::ActionType::Typecheck:
return withSemanticAnalysis(Instance, observer,
[](CompilerInstance &Instance) {
Expand Down
6 changes: 6 additions & 0 deletions test/Driver/emit-interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@
// CHECK-FILELIST: swift{{(-frontend|c)?(\.exe)?"?}} -frontend
// CHECK-FILELIST-SAME: -supplementary-output-file-map
// CHECK-FILELIST-NOT: emit-interface.swift{{ }}

// RUN: %swiftc_driver -driver-print-jobs -target x86_64-apple-macosx10.9 -experimental-lazy-typecheck %s -emit-module-interface -o %t/foo 2>&1 | %FileCheck -check-prefix=CHECK-LAZY-TYPECHECK %s

// CHECK-LAZY-TYPECHECK: swift{{(-frontend|c)?(\.exe)?"?}} -frontend
// CHECK-LAZY-TYPECHECK-SAME: -experimental-lazy-typecheck
// CHECK-LAZY-TYPECHECK-SAME: emit-interface.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -resolve-imports %s -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution
// RUN: %target-swift-frontend -experimental-lazy-typecheck %s -emit-module-interface-path %t/main.swiftinterface -enable-library-evolution
// RUN: %FileCheck %s < %t/main.swiftinterface

// CHECK: import Swift
Expand All @@ -22,4 +23,4 @@ public class C {}
// CHECK: }

// Globals
public var year = 2023
public var year = 2023
21 changes: 16 additions & 5 deletions test/TBD/resolve_imports.swift → test/TBD/lazy_typecheck.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -resolve-imports -emit-tbd -emit-tbd-path %t/resolve_imports.tbd %s -disable-availability-checking
// RUN: %target-swift-frontend -experimental-lazy-typecheck -emit-tbd -emit-tbd-path %t/lazy_typecheck.tbd %s -disable-availability-checking
// RUN: %FileCheck %s < %t/resolve_imports.tbd
// RUN: %FileCheck %s < %t/lazy_typecheck.tbd

// REQUIRES: OS=macosx

Expand All @@ -27,8 +29,17 @@ extension PrivateProto {

public struct S: PrivateProto {}

// CHECK: symbols: [ '_$s15resolve_imports1CCMa', '_$s15resolve_imports1CCMm',
// CHECK-NEXT: '_$s15resolve_imports1CCMn', '_$s15resolve_imports1CCN', '_$s15resolve_imports1CCfD',
// CHECK-NEXT: '_$s15resolve_imports1CCfd', '_$s15resolve_imports1SVMa',
// CHECK-NEXT: '_$s15resolve_imports1SVMn', '_$s15resolve_imports1SVN', '_$s15resolve_imports1SVSQAAMc',
// CHECK-NEXT: '_$s15resolve_imports1SVSQAASQ2eeoiySbx_xtFZTW', _main ]
// CHECK: symbols: [
// CHECK: '_$s14lazy_typecheck1CCMa',
// CHECK: '_$s14lazy_typecheck1CCMm',
// CHECK: '_$s14lazy_typecheck1CCMn',
// CHECK: '_$s14lazy_typecheck1CCN',
// CHECK: '_$s14lazy_typecheck1CCfD',
// CHECK: '_$s14lazy_typecheck1CCfd',
// CHECK: '_$s14lazy_typecheck1SVMa',
// CHECK: '_$s14lazy_typecheck1SVMn',
// CHECK: '_$s14lazy_typecheck1SVN',
// CHECK: '_$s14lazy_typecheck1SVSQAAMc',
// CHECK: '_$s14lazy_typecheck1SVSQAASQ2eeoiySbx_xtFZTW',
// CHECK: _main
// CHECK: ]