Skip to content

Commit 7a4d20b

Browse files
committed
Consolidate DiagnosticHelper consumer setup
With frontend parseable-output removed, `DiagnosticHelper::initDiagnosticConsumers()` depends only on the parsed `CompilerInvocation` and can be invoked once, at the same site that constructs the helper. Move the `libSwiftScan` replay caller to call it immediately after `DiagnosticHelper::create()`, drop the call from `replayCachedCompilerOutputsImpl`, and remove the now-unused `DiagnosticHelper` parameter from both `replayCachedCompilerOutputsImpl` and the public `replayCachedCompilerOutputsForInput`.
1 parent 0335df7 commit 7a4d20b

3 files changed

Lines changed: 6 additions & 13 deletions

File tree

include/swift/Frontend/CachingUtils.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929

3030
namespace swift {
3131

32-
class DiagnosticHelper;
33-
3432
/// Create a swift caching output backend that stores the output from
3533
/// compiler into a CAS.
3634
llvm::IntrusiveRefCntPtr<cas::SwiftCASOutputBackend>
@@ -59,7 +57,6 @@ bool replayCachedCompilerOutputsForInput(llvm::cas::ObjectStore &CAS,
5957
const InputFile &Input,
6058
unsigned InputIndex,
6159
DiagnosticEngine &Diag,
62-
DiagnosticHelper &DiagHelper,
6360
llvm::vfs::OutputBackend &OutBackend,
6461
const FrontendOptions &Opts,
6562
CachingDiagnosticsProcessor &CDP,

lib/Frontend/CachingUtils.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "swift/Frontend/CASOutputBackends.h"
2323
#include "swift/Frontend/CompileJobCacheKey.h"
2424
#include "swift/Frontend/CompileJobCacheResult.h"
25-
#include "swift/Frontend/DiagnosticHelper.h"
2625
#include "swift/Frontend/FrontendOptions.h"
2726
#include "swift/Frontend/MakeStyleDependencies.h"
2827
#include "swift/Option/Options.h"
@@ -164,7 +163,7 @@ static llvm::vfs::OutputConfig getOutputConfig(file_types::ID Type) {
164163
static bool replayCachedCompilerOutputsImpl(
165164
ArrayRef<CacheInputEntry> Inputs, ObjectStore &CAS, DiagnosticEngine &Diag,
166165
const FrontendOptions &Opts, CachingDiagnosticsProcessor &CDP,
167-
DiagnosticHelper *DiagHelper, OutputBackend &Backend, bool CacheRemarks,
166+
OutputBackend &Backend, bool CacheRemarks,
168167
bool UseCASBackend, bool WriteOutputHashXAttr) {
169168
bool CanReplayAllOutput = true;
170169
struct OutputEntry {
@@ -284,9 +283,6 @@ static bool replayCachedCompilerOutputsImpl(
284283
// Replay Diagnostics first so the output failures comes after.
285284
// Also if the diagnostics replay failed, proceed to re-compile.
286285
if (DiagnosticsOutput) {
287-
// Only set up the diagnostic consumers if there are diagnostics to replay.
288-
if (DiagHelper)
289-
DiagHelper->initDiagnosticConsumers();
290286
if (auto E =
291287
CDP.replayCachedDiagnostics(DiagnosticsOutput->Proxy.getData())) {
292288
Diag.diagnose(SourceLoc(), diag::error_replay_cached_diag,
@@ -408,21 +404,20 @@ bool replayCachedCompilerOutputs(
408404

409405
// Use on disk output backend directly here to write to disk.
410406
llvm::vfs::OnDiskOutputBackend Backend;
411-
return replayCachedCompilerOutputsImpl(Inputs, CAS, Diag, Opts, CDP,
412-
/*DiagHelper=*/nullptr, Backend,
407+
return replayCachedCompilerOutputsImpl(Inputs, CAS, Diag, Opts, CDP, Backend,
413408
CacheRemarks, UseCASBackend,
414409
WriteOutputHashXAttr);
415410
}
416411

417412
bool replayCachedCompilerOutputsForInput(
418413
ObjectStore &CAS, ObjectRef OutputRef, const InputFile &Input,
419-
unsigned InputIndex, DiagnosticEngine &Diag, DiagnosticHelper &DiagHelper,
414+
unsigned InputIndex, DiagnosticEngine &Diag,
420415
OutputBackend &OutBackend, const FrontendOptions &Opts,
421416
CachingDiagnosticsProcessor &CDP, bool CacheRemarks, bool UseCASBackend,
422417
bool WriteOutputHashXAttr) {
423418
llvm::SmallVector<CacheInputEntry> Inputs = {{Input, InputIndex, OutputRef}};
424419
return replayCachedCompilerOutputsImpl(Inputs, CAS, Diag, Opts, CDP,
425-
&DiagHelper, OutBackend, CacheRemarks,
420+
OutBackend, CacheRemarks,
426421
UseCASBackend, WriteOutputHashXAttr);
427422
}
428423

lib/Tooling/libSwiftScan/SwiftCaching.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ static llvm::Error replayCompilation(SwiftScanReplayInstance &Instance,
987987

988988
// Setup DiagnosticsConsumers.
989989
DiagnosticHelper DH = DiagnosticHelper::create(Inst, Invocation, Err);
990+
DH.initDiagnosticConsumers();
990991

991992
std::string InstanceSetupError;
992993
if (Inst.setupForReplay(Instance.Invocation, InstanceSetupError,
@@ -1007,7 +1008,7 @@ static llvm::Error replayCompilation(SwiftScanReplayInstance &Instance,
10071008
makeIntrusiveRefCnt<llvm::vfs::OnDiskOutputBackend>(), Out);
10081009

10091010
if (!replayCachedCompilerOutputsForInput(
1010-
CAS, Comp.Output, Input, Comp.InputIndex, Inst.getDiags(), DH,
1011+
CAS, Comp.Output, Input, Comp.InputIndex, Inst.getDiags(),
10111012
Backend, Instance.Invocation.getFrontendOptions(), *CDP, Remarks,
10121013
UseCASBackend,
10131014
Instance.Invocation.getCASOptions().WriteOutputHashXAttr)) {

0 commit comments

Comments
 (0)