Skip to content

Commit 8bd4ac8

Browse files
[CachedDiags] Don't cache diagnostics if command-line failed
1 parent 359c37e commit 8bd4ac8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,6 +2076,11 @@ int swift::performFrontend(ArrayRef<const char *> Args,
20762076
auto finishDiagProcessing = [&](int retValue, bool verifierEnabled) -> int {
20772077
FinishDiagProcessingCheckRAII.CalledFinishDiagProcessing = true;
20782078
PDC.setSuppressOutput(false);
2079+
if (auto *CDP = Instance->getCachingDiagnosticsProcessor()) {
2080+
// Don't cache if build failed.
2081+
if (retValue)
2082+
CDP->endDiagnosticCapture();
2083+
}
20792084
bool diagnosticsError = Instance->getDiags().finishProcessing();
20802085
// If the verifier is enabled and did not encounter any verification errors,
20812086
// return 0 even if the compile failed. This behavior isn't ideal, but large
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: not %target-swift-frontend -emit-module -emit-module-path %t/test.module \
2+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/test.module \
33
// RUN: -enable-cas -cas-path %t/cas -allow-unstable-cache-key-for-testing %s 2>&1 | %FileCheck %s
44
// RUN: %cache-tool -cas-path %t/cas -cache-tool-action print-output-keys -- \
55
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/test.module -enable-cas -cas-path %t/cas \
@@ -9,7 +9,7 @@
99
// RUN: -allow-unstable-cache-key-for-testing %s 2>&1 | %FileCheck %s
1010

1111
#sourceLocation(file: "anything.swift", line: 1)
12-
func 1() {}
12+
#warning("this is a warning")
1313
#sourceLocation()
1414

15-
// CHECK: anything.swift:1:6: error: function name
15+
// CHECK: anything.swift:1:10: warning: this is a warning

0 commit comments

Comments
 (0)