Skip to content

Commit 8ea2d0d

Browse files
committed
[BatchMode] Avoid spurious warnings in sourcekitd and indexing
Explicitly disable batch mode in createCompilerInvocation, since it uses -force-single-frontend-invocation. Previously we were getting spurious warnings. Also add a test that -disable-batch-mode will allow commands that use -index-file to avoid the same warning, since that is likely what they want to do as well. rdar://39581506
1 parent 71e72d8 commit 8ea2d0d

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

lib/Driver/FrontendUtil.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ swift::driver::createCompilerInvocation(ArrayRef<const char *> Argv,
3434
// frontend command.
3535
Args.push_back("-force-single-frontend-invocation");
3636

37+
// Explictly disable batch mode to avoid a spurious warning when combining
38+
// -enable-batch-mode with -force-single-frontend-invocation. This is an
39+
// implementation detail.
40+
Args.push_back("-disable-batch-mode");
41+
3742
// Avoid using filelists
3843
std::string neverThreshold =
3944
std::to_string(Compilation::NEVER_USE_FILELIST);

test/Driver/batch_mode_with_WMO_or_index.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
// RUN: %FileCheck -check-prefix CHECK-INDEX %s <%t/stderr_batch_index
1414
// CHECK-INDEX: warning: ignoring '-enable-batch-mode' because '-index-file' was also specified
1515
//
16+
// RUN: %swiftc_driver -disable-batch-mode -index-file %S/../Inputs/empty.swift -### 2>%t/stderr_nobatch_index | %FileCheck %s
17+
// RUN: %swiftc_driver -enable-batch-mode -index-file %S/../Inputs/empty.swift -disable-batch-mode -### 2>%t/stderr_batch_nobatch_index | %FileCheck %s
18+
// RUN: %FileCheck -allow-empty -check-prefix CHECK-INDEX-DISABLED %s <%t/stderr_nobatch_index
19+
// RUN: %FileCheck -allow-empty -check-prefix CHECK-INDEX-DISABLED %s <%t/stderr_batch_nobatch_index
20+
// CHECK-INDEX-DISABLED-NOT: warning
21+
//
1622
// This next one is a regression test for a specific failure in the past: wmo +
1723
// batch mode should not just result in wmo, but also preserve the num-threads
1824
// argument and (crucially) the resulting fact that the single wmo subprocess

test/Driver/createCompilerInvocation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
// 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
44
// RUN: not %swift-ide-test_plain -test-createCompilerInvocation -typecheck %s -emit-module-path %t.swiftmodule 2>&1 | %FileCheck --check-prefix=CHECK-FAIL %s
55
// RUN: not %swift-ide-test_plain -test-createCompilerInvocation -v 2>&1 | %FileCheck --check-prefix=CHECK-FAIL %s
6+
// RUN: %swift-ide-test_plain -test-createCompilerInvocation %s -enable-batch-mode 2>&1 | %FileCheck -allow-empty -check-prefix=CHECK-NOWARN %s
67

78
// CHECK-FAIL: error: unable to create a CompilerInvocation
9+
// CHECK-NOWARN-NOT: warning

test/SourceKit/CompileNotifications/diagnostics.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@
6464
// INVALID_ARG_CLANG-NEXT: key.severity: source.diagnostic.severity.warning,
6565
// INVALID_ARG_CLANG-NEXT: key.offset: 0
6666
// INVALID_ARG_CLANG-NEXT: key.description: "argument unused
67+
68+
// Ignore the spurious -wmo + -enable-batch-mode warning.
69+
// RUN: %sourcekitd-test -req=track-compiles == -req=sema %s -- %s -enable-batch-mode | %FileCheck %s -check-prefix=NODIAGS
70+
// RUN: %sourcekitd-test -req=track-compiles == -req=complete -offset=0 %s -- %s -enable-batch-mode | %FileCheck %s -check-prefix=NODIAGS

0 commit comments

Comments
 (0)