@@ -370,7 +370,7 @@ static Expected<llvm::cas::CASID> scanAndUpdateCC1InlineWithTool(
370
370
static llvm::Expected<llvm::cas::CASID> scanAndUpdateCC1UsingDaemon (
371
371
const char *Exec, ArrayRef<const char *> OldArgs,
372
372
StringRef WorkingDirectory, SmallVectorImpl<const char *> &NewArgs,
373
- bool &DiagnosticErrorOccurred , StringRef Path,
373
+ StringRef &DiagnosticOutput , StringRef Path,
374
374
const DepscanSharing &Sharing,
375
375
llvm::function_ref<const char *(const Twine &)> SaveArg,
376
376
llvm::cas::ObjectStore &CAS) {
@@ -394,7 +394,6 @@ static llvm::Expected<llvm::cas::CASID> scanAndUpdateCC1UsingDaemon(
394
394
llvm::BumpPtrAllocator Alloc;
395
395
llvm::StringSaver Saver (Alloc);
396
396
SmallVector<const char *> RawNewArgs;
397
- StringRef DiagnosticOutput;
398
397
CC1DepScanDProtocol::ResultKind Result;
399
398
StringRef FailedReason;
400
399
StringRef RootID;
@@ -411,11 +410,6 @@ static llvm::Expected<llvm::cas::CASID> scanAndUpdateCC1UsingDaemon(
411
410
for (int I = 0 , E = RawNewArgs.size (); I != E; ++I)
412
411
NewArgs[I] = SaveArg (RawNewArgs[I]);
413
412
414
- DiagnosticErrorOccurred = !DiagnosticOutput.empty ();
415
- if (DiagnosticErrorOccurred) {
416
- llvm::errs () << DiagnosticOutput;
417
- }
418
-
419
413
return CAS.parseID (RootID);
420
414
}
421
415
@@ -510,19 +504,22 @@ static int scanAndUpdateCC1(const char *Exec, ArrayRef<const char *> OldArgs,
510
504
if (ProduceIncludeTree)
511
505
Sharing.CASArgs .push_back (" -fdepscan-include-tree" );
512
506
507
+ StringRef DiagnosticOutput;
513
508
bool DiagnosticErrorOccurred = false ;
514
509
auto ScanAndUpdate = [&]() {
515
510
if (std::optional<std::string> DaemonPath =
516
511
makeDepscanDaemonPath (Mode, Sharing))
517
512
return scanAndUpdateCC1UsingDaemon (Exec, OldArgs, WorkingDirectory,
518
- NewArgs, DiagnosticErrorOccurred ,
519
- *DaemonPath, Sharing, SaveArg, *DB);
513
+ NewArgs, DiagnosticOutput, *DaemonPath ,
514
+ Sharing, SaveArg, *DB);
520
515
return scanAndUpdateCC1Inline (Exec, OldArgs, WorkingDirectory, NewArgs,
521
516
ProduceIncludeTree, DiagnosticErrorOccurred,
522
517
SaveArg, CASOpts, DB, Cache);
523
518
};
524
519
if (llvm::Error E = ScanAndUpdate ().moveInto (RootID)) {
525
520
Diag.Report (diag::err_cas_depscan_failed) << std::move (E);
521
+ if (!DiagnosticOutput.empty ())
522
+ llvm::errs () << DiagnosticOutput;
526
523
return 1 ;
527
524
}
528
525
return DiagnosticErrorOccurred;
@@ -959,7 +956,8 @@ int ScanServer::listen() {
959
956
*Tool, *DiagsConsumer, &DiagsOS, Argv0, Args, WorkingDirectory,
960
957
NewArgs, *CAS, [&](const Twine &T) { return Saver.save (T).data (); });
961
958
if (!RootID) {
962
- consumeError (Comms.putScanResultFailed (toString (RootID.takeError ())));
959
+ consumeError (Comms.putScanResultFailed (toString (RootID.takeError ()),
960
+ DiagsOS.str ()));
963
961
SharedOS.applyLocked ([&](raw_ostream &OS) {
964
962
printScannedCC1 (OS);
965
963
OS << I << " : failed to create compiler invocation\n " ;
0 commit comments