Skip to content

Commit 75116e9

Browse files
committed
[NFC] Inline CompilerInstance::setUpForInput
1 parent c3e33be commit 75116e9

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

include/swift/Frontend/Frontend.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,6 @@ class CompilerInstance {
576576
void setupDependencyTrackerIfNeeded();
577577
Optional<unsigned> setUpCodeCompletionBuffer();
578578

579-
/// Set up all state in the CompilerInstance to process the given input file.
580-
/// Return true on error.
581-
bool setUpForInput(const InputFile &input);
582-
583579
/// Find a buffer for a given input file and ensure it is recorded in
584580
/// SourceMgr, PartialModules, or InputSourceCodeBufferIDs as appropriate.
585581
/// Return the buffer ID if it is not already compiled, or None if so.

lib/Frontend/Frontend.cpp

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,20 @@ bool CompilerInstance::setUpInputs() {
598598
// per-input setup.
599599
const Optional<unsigned> codeCompletionBufferID = setUpCodeCompletionBuffer();
600600

601-
for (const InputFile &input :
602-
Invocation.getFrontendOptions().InputsAndOutputs.getAllInputs())
603-
if (setUpForInput(input))
601+
const auto &Inputs =
602+
Invocation.getFrontendOptions().InputsAndOutputs.getAllInputs();
603+
for (const InputFile &input : Inputs) {
604+
bool failed = false;
605+
Optional<unsigned> bufferID = getRecordedBufferID(input, failed);
606+
if (failed)
604607
return true;
605608

609+
if (!bufferID.hasValue() || !input.isPrimary())
610+
continue;
611+
612+
recordPrimaryInputBuffer(*bufferID);
613+
}
614+
606615
// Set the primary file to the code-completion point if one exists.
607616
if (codeCompletionBufferID.hasValue() &&
608617
!isPrimaryInput(*codeCompletionBufferID)) {
@@ -619,23 +628,6 @@ bool CompilerInstance::setUpInputs() {
619628
return false;
620629
}
621630

622-
bool CompilerInstance::setUpForInput(const InputFile &input) {
623-
bool failed = false;
624-
Optional<unsigned> bufferID = getRecordedBufferID(input, failed);
625-
if (failed)
626-
return true;
627-
if (!bufferID)
628-
return false;
629-
630-
if (isInputSwift() &&
631-
llvm::sys::path::filename(input.file()) == "main.swift") {
632-
assert(MainBufferID == NO_SUCH_BUFFER && "re-setting MainBufferID");
633-
MainBufferID = *bufferID;
634-
}
635-
636-
if (input.isPrimary()) {
637-
recordPrimaryInputBuffer(*bufferID);
638-
}
639631
return false;
640632
}
641633

0 commit comments

Comments
 (0)