@@ -599,10 +599,14 @@ bool CompilerInstance::setUpInputs() {
599
599
600
600
const auto &Inputs =
601
601
Invocation.getFrontendOptions ().InputsAndOutputs .getAllInputs ();
602
+ const bool shouldRecover = Invocation.getFrontendOptions ()
603
+ .InputsAndOutputs .shouldRecoverMissingInputs ();
604
+
602
605
bool hasFailed = false ;
603
606
for (const InputFile &input : Inputs) {
604
607
bool failed = false ;
605
- Optional<unsigned > bufferID = getRecordedBufferID (input, failed);
608
+ Optional<unsigned > bufferID =
609
+ getRecordedBufferID (input, shouldRecover, failed);
606
610
hasFailed |= failed;
607
611
608
612
if (!bufferID.hasValue () || !input.isPrimary ())
@@ -623,8 +627,9 @@ bool CompilerInstance::setUpInputs() {
623
627
return false ;
624
628
}
625
629
626
- Optional<unsigned > CompilerInstance::getRecordedBufferID (const InputFile &input,
627
- bool &failed) {
630
+ Optional<unsigned >
631
+ CompilerInstance::getRecordedBufferID (const InputFile &input,
632
+ const bool shouldRecover, bool &failed) {
628
633
if (!input.getBuffer ()) {
629
634
if (Optional<unsigned > existingBufferID =
630
635
SourceMgr.getIDForBufferIdentifier (input.getFileName ())) {
@@ -633,11 +638,9 @@ Optional<unsigned> CompilerInstance::getRecordedBufferID(const InputFile &input,
633
638
}
634
639
auto buffers = getInputBuffersIfPresent (input);
635
640
636
- // For non-primary '.swift' files, recover by dummy buffer so that the primary
637
- // files are diagnosed. Also, IDE functionalities want to proceed even with
638
- // missing files.
639
- if (!buffers.hasValue () && input.getType () == file_types::TY_Swift &&
640
- !input.isPrimary ()) {
641
+ // Recover by dummy buffer if requested.
642
+ if (!buffers.hasValue () && shouldRecover &&
643
+ input.getType () == file_types::TY_Swift && !input.isPrimary ()) {
641
644
buffers = ModuleBuffers (llvm::MemoryBuffer::getMemBuffer (
642
645
" // missing file\n " , input.getFileName ()));
643
646
}
0 commit comments