mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Frontend] Recover missing input file by dummy input buffer.
Also, continue trying opening files even if any of primary files are missing so that the caller can know all files failed to open. rdar://problem/33757793
This commit is contained in:
@@ -599,17 +599,19 @@ bool CompilerInstance::setUpInputs() {
|
||||
|
||||
const auto &Inputs =
|
||||
Invocation.getFrontendOptions().InputsAndOutputs.getAllInputs();
|
||||
bool hasFailed = false;
|
||||
for (const InputFile &input : Inputs) {
|
||||
bool failed = false;
|
||||
Optional<unsigned> bufferID = getRecordedBufferID(input, failed);
|
||||
if (failed)
|
||||
return true;
|
||||
hasFailed |= failed;
|
||||
|
||||
if (!bufferID.hasValue() || !input.isPrimary())
|
||||
continue;
|
||||
|
||||
recordPrimaryInputBuffer(*bufferID);
|
||||
}
|
||||
if (hasFailed)
|
||||
return true;
|
||||
|
||||
// Set the primary file to the code-completion point if one exists.
|
||||
if (codeCompletionBufferID.hasValue() &&
|
||||
@@ -631,6 +633,15 @@ Optional<unsigned> CompilerInstance::getRecordedBufferID(const InputFile &input,
|
||||
}
|
||||
auto buffers = getInputBuffersIfPresent(input);
|
||||
|
||||
// For non-primary '.swift' files, recover by dummy buffer so that the primary
|
||||
// files are diagnosed. Also, IDE functionalities want to proceed even with
|
||||
// missing files.
|
||||
if (!buffers.hasValue() && input.getType() == file_types::TY_Swift &&
|
||||
!input.isPrimary()) {
|
||||
buffers = ModuleBuffers(llvm::MemoryBuffer::getMemBuffer(
|
||||
"// missing file\n", input.getFileName()));
|
||||
}
|
||||
|
||||
if (!buffers.hasValue()) {
|
||||
failed = true;
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user