Skip to content

Commit d736106

Browse files
Merge pull request #75555 from cachemeifyoucan/eng/PR-132758308
[Caching] Use `swift-frontend` as executable name in replays
2 parents 9753d7c + 61e725f commit d736106

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

lib/Frontend/DiagnosticHelper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ static DetailedTaskDescription constructDetailedTaskDescription(
347347
ArrayRef<const char *> Args, bool isEmitModuleOnly = false) {
348348
// Command line and arguments
349349
std::string Executable = Invocation.getFrontendOptions().MainExecutablePath;
350+
// If main executable path is never set, use `swift-frontend` as placeholder.
351+
if (Executable.empty())
352+
Executable = "swift-frontend";
350353
SmallVector<std::string, 16> Arguments;
351354
std::string CommandLine;
352355
SmallVector<CommandInput, 4> Inputs;

test/CAS/swift-scan-diagnostics-batch.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050

5151
// PARSEABLE-COUNT-1: "kind": "began",
5252
// PARSEABLE-COUNT-1: "kind": "finished",
53-
// PRASEABLE-NOT: "kind": "began",
54-
// PRASEABLE-NOT: "kind": "finished",
5553

5654
// NO-OUTPUT-NOT: "kind": "began",
5755

test/CAS/swift-scan-diagnostics.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
// PARSEABLE-NEXT: {
5555
// PARSEABLE-NEXT: "kind": "began",
5656
// PARSEABLE-NEXT: "name": "compile",
57+
// PARSEABLE-NEXT: "command": "swift-frontend
5758

5859
// PARSEABLE: "kind": "finished",
5960
// PARSEABLE-NEXT: "name": "compile",

tools/libSwiftScan/SwiftCaching.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,8 @@ computeCacheKey(llvm::cas::ObjectStore &CAS, llvm::ArrayRef<const char *> Args,
276276
swift::CompilerInvocation Invocation;
277277
swift::SourceManager SourceMgr;
278278
swift::DiagnosticEngine Diags(SourceMgr);
279-
llvm::SmallString<128> workingDirectory;
280-
llvm::sys::fs::current_path(workingDirectory);
281-
llvm::SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4>
282-
configurationFileBuffers;
283279

284-
std::string MainExecutablePath = llvm::sys::fs::getMainExecutable(
285-
"swift-frontend", (void *)swiftscan_cache_replay_compilation);
286-
287-
if (Invocation.parseArgs(Args, Diags, &configurationFileBuffers,
288-
workingDirectory, MainExecutablePath))
280+
if (Invocation.parseArgs(Args, Diags, nullptr, {}))
289281
return llvm::createStringError(llvm::inconvertibleErrorCode(),
290282
"Argument parsing failed");
291283

@@ -826,11 +818,7 @@ swiftscan_cache_replay_instance_create(int argc, const char **argv,
826818
swift::DiagnosticEngine DE(SrcMgr);
827819
DE.addConsumer(Diags);
828820

829-
std::string MainExecutablePath = llvm::sys::fs::getMainExecutable(
830-
"swift-frontend", (void *)swiftscan_cache_replay_compilation);
831-
832-
if (Instance->Invocation.parseArgs(Args, DE, nullptr, {},
833-
MainExecutablePath)) {
821+
if (Instance->Invocation.parseArgs(Args, DE, nullptr, {})) {
834822
delete Instance;
835823
*error = swift::c_string_utils::create_clone(err_msg.c_str());
836824
return nullptr;
@@ -981,8 +969,11 @@ static llvm::Error replayCompilation(SwiftScanReplayInstance &Instance,
981969
DH.initDiagConsumers(Invocation);
982970
DH.beginMessage(Invocation, Instance.Args);
983971

984-
if (auto E = CDP->replayCachedDiagnostics(DiagnosticsOutput->getData()))
972+
if (auto E = CDP->replayCachedDiagnostics(DiagnosticsOutput->getData())) {
973+
DH.endMessage(/*ReturnCode=*/1);
974+
Inst.getDiags().finishProcessing();
985975
return E;
976+
}
986977

987978
if (Remarks)
988979
Inst.getDiags().diagnose(SourceLoc(), diag::replay_output,

0 commit comments

Comments
 (0)