mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[NFC] Remove CompilerInstance::setSILModule
The REPL was using the CompilerInstance to stash this parameter, then it would immediately move it into IRGen. Drop the setter and pass this data directly.
This commit is contained in:
@@ -484,11 +484,6 @@ public:
|
||||
}
|
||||
DependencyTracker *getDependencyTracker() { return DepTracker.get(); }
|
||||
|
||||
/// Set the SIL module for this compilation instance.
|
||||
///
|
||||
/// The CompilerInstance takes ownership of the given SILModule object.
|
||||
void setSILModule(std::unique_ptr<SILModule> M);
|
||||
|
||||
SILModule *getSILModule() {
|
||||
return TheSILModule.get();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#ifndef SWIFT_IMMEDIATE_IMMEDIATE_H
|
||||
#define SWIFT_IMMEDIATE_IMMEDIATE_H
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -25,6 +26,7 @@ namespace swift {
|
||||
class CompilerInstance;
|
||||
class IRGenOptions;
|
||||
class SILOptions;
|
||||
class SILModule;
|
||||
|
||||
// Using LLVM containers to store command-line arguments turns out
|
||||
// to be a lose, because LLVM's execution engine demands this vector
|
||||
@@ -37,7 +39,8 @@ namespace swift {
|
||||
///
|
||||
/// \return the result returned from main(), if execution succeeded
|
||||
int RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
|
||||
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts);
|
||||
const IRGenOptions &IRGenOpts, const SILOptions &SILOpts,
|
||||
std::unique_ptr<SILModule> &&SM);
|
||||
|
||||
void runREPL(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
|
||||
bool ParseStdlib);
|
||||
|
||||
@@ -185,10 +185,6 @@ void CompilerInstance::createSILModule() {
|
||||
Invocation.getFrontendOptions().InputsAndOutputs.isWholeModule());
|
||||
}
|
||||
|
||||
void CompilerInstance::setSILModule(std::unique_ptr<SILModule> M) {
|
||||
TheSILModule = std::move(M);
|
||||
}
|
||||
|
||||
void CompilerInstance::recordPrimaryInputBuffer(unsigned BufID) {
|
||||
PrimaryBufferIDs.insert(BufID);
|
||||
}
|
||||
@@ -618,7 +614,7 @@ std::unique_ptr<SILModule> CompilerInstance::takeSILModule() {
|
||||
return std::move(TheSILModule);
|
||||
}
|
||||
|
||||
ModuleDecl *CompilerInstance::getMainModule() {
|
||||
ModuleDecl *CompilerInstance::getMainModule() const {
|
||||
if (!MainModule) {
|
||||
Identifier ID = Context->getIdentifier(Invocation.getModuleName());
|
||||
MainModule = ModuleDecl::create(ID, *Context);
|
||||
|
||||
@@ -1383,7 +1383,7 @@ static void generateIR(const IRGenOptions &IRGenOpts,
|
||||
|
||||
static bool processCommandLineAndRunImmediately(const CompilerInvocation &Invocation,
|
||||
CompilerInstance &Instance,
|
||||
std::unique_ptr<SILModule> SM,
|
||||
std::unique_ptr<SILModule> &&SM,
|
||||
ModuleOrSourceFile MSF,
|
||||
FrontendObserver *observer,
|
||||
int &ReturnValue) {
|
||||
@@ -1392,8 +1392,6 @@ static bool processCommandLineAndRunImmediately(const CompilerInvocation &Invoca
|
||||
const IRGenOptions &IRGenOpts = Invocation.getIRGenOptions();
|
||||
const ProcessCmdLine &CmdLine =
|
||||
ProcessCmdLine(opts.ImmediateArgv.begin(), opts.ImmediateArgv.end());
|
||||
Instance.setSILModule(std::move(SM));
|
||||
|
||||
|
||||
PrettyStackTraceStringAction trace(
|
||||
"running user code",
|
||||
|
||||
@@ -237,7 +237,8 @@ bool swift::immediate::autolinkImportedModules(ModuleDecl *M,
|
||||
int swift::RunImmediately(CompilerInstance &CI,
|
||||
const ProcessCmdLine &CmdLine,
|
||||
const IRGenOptions &IRGenOpts,
|
||||
const SILOptions &SILOpts) {
|
||||
const SILOptions &SILOpts,
|
||||
std::unique_ptr<SILModule> &&SM) {
|
||||
ASTContext &Context = CI.getASTContext();
|
||||
|
||||
// IRGen the main module.
|
||||
@@ -246,7 +247,7 @@ int swift::RunImmediately(CompilerInstance &CI,
|
||||
// FIXME: We shouldn't need to use the global context here, but
|
||||
// something is persisting across calls to performIRGeneration.
|
||||
auto ModuleOwner = performIRGeneration(
|
||||
IRGenOpts, swiftModule, CI.takeSILModule(), swiftModule->getName().str(),
|
||||
IRGenOpts, swiftModule, std::move(SM), swiftModule->getName().str(),
|
||||
PSPs, getGlobalLLVMContext(), ArrayRef<std::string>());
|
||||
auto *Module = ModuleOwner.get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user