@@ -765,13 +765,13 @@ static void printOrDumpDecl(Decl *d, PrintOrDump which) {
765
765
766
766
// / The compiler and execution environment for the REPL.
767
767
class REPLEnvironment {
768
+ std::unique_ptr<llvm::LLVMContext> LLVMContext;
768
769
CompilerInstance &CI;
769
770
ModuleDecl *MostRecentModule;
770
771
ProcessCmdLine CmdLine;
771
772
llvm::SmallPtrSet<swift::ModuleDecl *, 8 > ImportedModules;
772
773
SmallVector<llvm::Function*, 8 > InitFns;
773
774
bool RanGlobalInitializers;
774
- llvm::LLVMContext &LLVMContext;
775
775
llvm::Module *Module;
776
776
llvm::StringSet<> FuncsAlreadyGenerated;
777
777
llvm::StringSet<> GlobalsAlreadyEmitted;
@@ -1028,15 +1028,14 @@ class REPLEnvironment {
1028
1028
public:
1029
1029
REPLEnvironment (CompilerInstance &CI,
1030
1030
const ProcessCmdLine &CmdLine,
1031
- llvm::LLVMContext &LLVMCtx,
1032
1031
bool ParseStdlib)
1033
- : CI(CI),
1032
+ : LLVMContext(std::make_unique<llvm::LLVMContext>()),
1033
+ CI (CI),
1034
1034
MostRecentModule(CI.getMainModule()),
1035
1035
CmdLine(CmdLine),
1036
1036
RanGlobalInitializers(false ),
1037
- LLVMContext(LLVMCtx),
1038
- Module(new llvm::Module(" REPL" , LLVMContext)),
1039
- DumpModule(" REPL" , LLVMContext),
1037
+ Module(new llvm::Module(" REPL" , *LLVMContext.get())),
1038
+ DumpModule(" REPL" , *LLVMContext.get()),
1040
1039
IRGenOpts(),
1041
1040
SILOpts(),
1042
1041
Input(*this )
@@ -1281,7 +1280,7 @@ void PrettyStackTraceREPL::print(llvm::raw_ostream &out) const {
1281
1280
1282
1281
void swift::runREPL (CompilerInstance &CI, const ProcessCmdLine &CmdLine,
1283
1282
bool ParseStdlib) {
1284
- REPLEnvironment env (CI, CmdLine, getGlobalLLVMContext (), ParseStdlib);
1283
+ REPLEnvironment env (CI, CmdLine, ParseStdlib);
1285
1284
if (CI.getASTContext ().hadError ())
1286
1285
return ;
1287
1286
0 commit comments