Skip to content

[SR-2400] Add -continue-building-after-errors #4437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
4 changes: 4 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ def warnings_as_errors : Flag<["-"], "warnings-as-errors">,
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
HelpText<"Treat warnings as errors">;

def continue_building_after_errors : Flag<["-"], "continue-building-after-errors">,
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
HelpText<"Continue building, even after errors are encountered">;

// Platform options.
def enable_app_extension : Flag<["-"], "application-extension">,
Flags<[FrontendOption, NoInteractiveOption]>,
Expand Down
9 changes: 6 additions & 3 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ std::unique_ptr<Compilation> Driver::buildCompilation(
!ArgList->hasArg(options::OPT_embed_bitcode);

bool SaveTemps = ArgList->hasArg(options::OPT_save_temps);
bool ContinueBuildingAfterErrors =
ArgList->hasArg(options::OPT_continue_building_after_errors);

std::unique_ptr<DerivedArgList> TranslatedArgList(
translateInputArgs(*ArgList));
Expand Down Expand Up @@ -506,10 +508,11 @@ std::unique_ptr<Compilation> Driver::buildCompilation(
buildJobs(Actions, OI, OFM.get(), *TC, *C);

// For updating code we need to go through all the files and pick up changes,
// even if they have compiler errors.
// Also for getting bulk fixits.
// even if they have compiler errors. Also for getting bulk fixits, or for when
// users explicitly request to continue building despite errors.
if (OI.CompilerMode == OutputInfo::Mode::UpdateCode ||
OI.ShouldGenerateFixitEdits)
OI.ShouldGenerateFixitEdits ||
ContinueBuildingAfterErrors)
C->setContinueBuildingAfterErrors();

if (ShowIncrementalBuildDecisions)
Expand Down
6 changes: 6 additions & 0 deletions test/Driver/Inputs/error.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
struct Foo {
let bar: Int
init() {
self.bar = self.bar
}
}
13 changes: 13 additions & 0 deletions test/Driver/continue-building-after-errors.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: not %swiftc_driver %S/Inputs/error.swift %s 2>&1 | %FileCheck %s
// RUN: not %swiftc_driver -continue-building-after-errors %S/Inputs/error.swift %s 2>&1 | %FileCheck -check-prefix=CHECK-CONTINUE %s

// CHECK: self.bar = self.bar
// CHECK-NOT: self.baz = self.baz
// CHECK-CONTINUE: self.bar = self.bar
// CHECK-CONTINUE: self.baz = self.baz
struct Bar {
let baz: Int
init() {
self.baz = self.baz
}
}