Skip to content

[4.2] [BatchMode] Avoid spurious warnings in sourcekitd and indexing #16076

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 2 commits into from
Apr 23, 2018
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
5 changes: 5 additions & 0 deletions lib/Driver/FrontendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ swift::driver::createCompilerInvocation(ArrayRef<const char *> Argv,
// frontend command.
Args.push_back("-force-single-frontend-invocation");

// Explictly disable batch mode to avoid a spurious warning when combining
// -enable-batch-mode with -force-single-frontend-invocation. This is an
// implementation detail.
Args.push_back("-disable-batch-mode");

// Avoid using filelists
std::string neverThreshold =
std::to_string(Compilation::NEVER_USE_FILELIST);
Expand Down
12 changes: 12 additions & 0 deletions test/Driver/batch_mode_with_WMO_or_index.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
// RUN: %FileCheck -check-prefix CHECK-INDEX %s <%t/stderr_batch_index
// CHECK-INDEX: warning: ignoring '-enable-batch-mode' because '-index-file' was also specified
//
// The following test is verifying that -disable-batch-mode overrides an earlier
// -enable-batch-mode and silences the warning about mixing batch mode with
// -index-file. Tools that take an existing command line and add -index-file can
// thus add -disable-batch-mode without having to otherwise interpret the
// arguments.
//
// RUN: %swiftc_driver -disable-batch-mode -index-file %S/../Inputs/empty.swift -### 2>%t/stderr_nobatch_index | %FileCheck %s
// RUN: %swiftc_driver -enable-batch-mode -index-file %S/../Inputs/empty.swift -disable-batch-mode -### 2>%t/stderr_batch_nobatch_index | %FileCheck %s
// RUN: %FileCheck -allow-empty -check-prefix CHECK-INDEX-DISABLED %s <%t/stderr_nobatch_index
// RUN: %FileCheck -allow-empty -check-prefix CHECK-INDEX-DISABLED %s <%t/stderr_batch_nobatch_index
// CHECK-INDEX-DISABLED-NOT: warning
//
// This next one is a regression test for a specific failure in the past: wmo +
// batch mode should not just result in wmo, but also preserve the num-threads
// argument and (crucially) the resulting fact that the single wmo subprocess
Expand Down
2 changes: 2 additions & 0 deletions test/Driver/createCompilerInvocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
// RUN: %swift-ide-test_plain -test-createCompilerInvocation -c %s %S/Input/main.swift %S/Input/lib.swift -module-name createCompilerInvocation -emit-module -emit-objc-header 2>&1
// RUN: not %swift-ide-test_plain -test-createCompilerInvocation -typecheck %s -emit-module-path %t.swiftmodule 2>&1 | %FileCheck --check-prefix=CHECK-FAIL %s
// RUN: not %swift-ide-test_plain -test-createCompilerInvocation -v 2>&1 | %FileCheck --check-prefix=CHECK-FAIL %s
// RUN: %swift-ide-test_plain -test-createCompilerInvocation %s -enable-batch-mode 2>&1 | %FileCheck -allow-empty -check-prefix=CHECK-NOWARN %s

// CHECK-FAIL: error: unable to create a CompilerInvocation
// CHECK-NOWARN-NOT: warning
4 changes: 4 additions & 0 deletions test/SourceKit/CompileNotifications/diagnostics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@
// INVALID_ARG_CLANG-NEXT: key.severity: source.diagnostic.severity.warning,
// INVALID_ARG_CLANG-NEXT: key.offset: 0
// INVALID_ARG_CLANG-NEXT: key.description: "argument unused

// Ignore the spurious -wmo + -enable-batch-mode warning.
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -- %s -enable-batch-mode | %FileCheck %s -check-prefix=NODIAGS
// RUN: %sourcekitd-test -req=track-compiles == -req=complete -offset=0 %s -- %s -enable-batch-mode | %FileCheck %s -check-prefix=NODIAGS